Skip to Content
0
Mar 18, 2015 at 12:44 AM

.csv files upload from windows batch file, IMPORT not able to access .ctl file

216 Views

Hi Guys,

I am trying to schedule the upload of a .csv file from windows batch file .bat

I am able to connect to HANA using HDBSECUSER store login and can execute every single SQL command through batch file, but not IMPORT or IMPORT FROM command.

Here is what I am doing.

1) I created a Batch file xxx.bat with the following

"C:\Program Files\sap\hdbclient\hdbsql" -U LSSxxx -c ";" -I "C:\Users\LSSRBD\Desktop\xxx\MBEW Upload\xxx.sql"

2) xxx.sql file contains:

DELETE FROM "XXX_CUSTOM"."XXX_UPLOAD";

IMPORT FROM CONTROL FILE 'C:\Users\LSSxxx\Desktop\xxx\XXX Upload\xxx.ctl';

3) xxx.ctl file contains:

IMPORT DATA INTO TABLE "XXX_CUSTOM"."XXX_UPLOAD" FROM 'C:\Users\LSSXXX\Desktop\xxx\xxx Upload\xxx201502.csv'

RECORD DELIMITED BY '\n'

FIELD DELIMITED BY ','

OPTIONALLY ENCLOSED BY '"'

when I try executing xxx.bat file from the command line, I am getting the following message.

general error: Cannot open Control file

So I gave the command: icacls "xxx.ctl" /grant Everyone:F from command line and it worked. So I am assuming this gave the permission to every one on the pc.

I am still getting the error: general error: Cannot open Control file.

What exactly is wrong that I am doing here? HDBSQL works with every SQL command I through onto HANA DB content, but IMPORT command is failing. How do I solve this issue?

IMPORT or IMPORT FROM Commands are SQL commands, Is not it, the xxx.sql file executes all other SQL commands but not these IMPORT* command(s).

Attachments

error.PNG (10.5 kB)