Can anyone find the problem with this simple code?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mirrormirror
Posts: 129
Joined: 08 Feb 2016 20:25

Can anyone find the problem with this simple code?

#1 Post by mirrormirror » 18 Jul 2016 17:37

It is probably a simple problem with parentheses ")" but I can't figure out exactly where the problem lies:

Code: Select all

@ECHO OFF

   SET "tmpImport1=dataRaw_Shares.txt"
   SET "tmpSQLImport1=Insert_Shares.sql"

   (
      @ECHO DELETE FROM Shares;
      @ECHO DROP TABLE IF EXISTS tmpDataInsert;
      @ECHO CREATE TEMP TABLE IF NOT EXISTS [tmpDataInsert] (
      @ECHO   [ShareNm] CHAR,
      @ECHO   [SharePath] CHAR);
      @ECHO .separator "|"
      @ECHO .import %tmpImport1% tmpDataInsert
      @ECHO SELECT * FROM tmpDataInsert;
      @ECHO INSERT INTO Shares(ShareNm, SharePath) SELECT * FROM tmpDataInsert;
      @ECHO DROP TABLE IF EXISTS tmpDataInsert;
   )>"%tmpSQLImport1%"


   TYPE "%tmpSQLImport1%"


Output:

Code: Select all

T:\>test
DELETE FROM Shares;
DROP TABLE IF EXISTS tmpDataInsert;
CREATE TEMP TABLE IF NOT EXISTS [tmpDataInsert] (
  [ShareNm] CHAR,
  [SharePath] CHAR
.separator "|"
.import dataRaw_Shares.txt tmpDataInsert
SELECT * FROM tmpDataInsert;
INSERT INTO Shares(ShareNm, SharePath) SELECT * FROM tmpDataInsert;
DROP TABLE IF EXISTS tmpDataInsert;
The system cannot find the file specified.

T:\>

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Can anyone find the problem with this simple code?

#2 Post by foxidrive » 18 Jul 2016 18:27

I didn't look deeply at all but replace ) with ^) when you echo them within parentheses.

mirrormirror
Posts: 129
Joined: 08 Feb 2016 20:25

Re: Can anyone find the problem with this simple code?

#3 Post by mirrormirror » 18 Jul 2016 19:50

I didn't look deeply at all but replace ) with ^) when you echo them within parentheses.


That fixed it - thanks.

Post Reply