cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

hdbsql - inline command to import database

chladek
Participant
0 Likes
1,075

Hello,
I would like to use bash script where beside other commands I have:

inline command:
./hdbsql -n localhost -u MYUSER -p <mypass> "IMPORT "SBODEMOCZ"."*" AS BINARY FROM '/mypath/SBODEMOCZ' WITH IGNORE EXISTING;"

but it returns:
* 257: sql syntax error: incorrect syntax near "*": line 1 col 18 (at pos 18) SQLSTATE: HY000

When I firstly login into hdbsql console:
./hdbsql -n localhost -u MYUSER -p <mypass>

then pass the command:
hdbsql NDB=>IMPORT "SBODEMOCZ"."*" AS BINARY FROM '/mypath/SBODEMOCZ' WITH IGNORE EXISTING;

it works properly.
Please how can I do it as inline command?

Thank You
Regards
Zdenek

Accepted Solutions (1)

Accepted Solutions (1)

jyotsana_gupta
Product and Topic Expert
Product and Topic Expert

Hello Zdenek,

I tried your inline command on Windows and Linux and got the same syntax error, but, if I escape the quotes around *, the syntax error goes away on both platforms. Could you please try that and see if it works for you as well? 
./hdbsql -n localhost -u MYUSER -p <mypass> "IMPORT "SBODEMOCZ".\"*\" AS BINARY FROM '/mypath/SBODEMOCZ' WITH IGNORE EXISTING;"

Best regards,
Jyotsana

chladek
Participant
Thank You with the escaping arround * it work.

Answers (1)

Answers (1)

mamartins
Active Contributor

You need to escape the " from the IMPORT command, otherwise the HDBSQL will interpret the second " as the end of the command.

Also, you could store the commands in a file and call the HDBSQL (option -I <file>) to execute them. Official documentation here.

Vitaliy-R
Developer Advocate
Developer Advocate
0 Likes

I do not think escape matters (but maybe for the versions of hdbsql?) as I can execute on Mac's terminal following without the issues:

hdbsql -U TECHED_DEMO_VECTOR -j "SELECT "Current_User" FROM \"DUMMY\""

VitaliyR_0-1716221258303.png