php ninja
php ninja

Reputation: 11

Execute Import / Load db2 command from PHP code

I am new to db2. I want to execute import command from my php code but I get following error. I have checked my db2 connection also it is working but command is not getting executed.

Command I used:

$output="IMPORT FROM receipt_master.del OF DEL INSERT INTO RECEIPT_MASTER (FIN_YEAR , TREA_CODE , MN_YY , MAJOR_HEAD , TRAN_ID , DATE , CHALLAN_NO)";

Error I am getting:

Warning: odbc_exec() [function.odbc-exec]:
SQL error: [IBM][CLI Driver][DB2/LINUXX8664] 
SQL0104N An unexpected token "receipt_master.del" was found following "IMPORT FROM ".
Expected tokens may include: "JOIN". SQLSTATE=42601 , SQL state 42601 in SQLExecDirect 

Upvotes: 1

Views: 290

Answers (1)

data_henrik
data_henrik

Reputation: 17118

IMPORT is not a regular SQL statement and hence cannot be executed the way you are attempting it. You could look into calling the ADMIN_CMD procedure. Basically, you would call a procedure from your code. That procedure would then execute the IMPORT command on your behalf. There is an entire section on using IMPORT within the ADMIN_CMD.

Upvotes: 1

Related Questions