cancel
Showing results for 
Search instead for 
Did you mean: 

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

vanama1
Explorer
0 Kudos

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).

Accepted Solutions (0)

Answers (1)

Answers (1)

lbreddemann
Active Contributor
0 Kudos

IMPORT DATA is a server side command (just as the documentation tells you)

The SAP HANA server cannot access your workstation or the folders on it.

This (and a lot more around data import/export) has been discussed a lot here in SCN already.

A little research effort would have clarified this.

- Lars