michaelthegriff
Programmer
I am not even sure I can do this, but I am trying to build/execute an IMPORT statement within a stored procedure and execute it. The problem is, the stored procedure builder for DB2 7.2 sp2 complains about the IMPORT statement during the PREPARE phase of execution. I have coded it so that it will take a variable string for the path/file-name, but even if I hard code this in the string (like below) it still complains about the statement. (I think part of my problem is how do you escape '\' and/or '/' in a stored proc?).
Here is essentially what I am trying to do:
-- Import the data into the seed table
SET stmt = 'IMPORT FROM d:\event00.del OF DEL MESSAGES importmsgs.txt INSERT INTO ' || table_n;
PREPARE s2 FROM stmt;
EXECUTE s2;
But upon execution, the spb gives me the following:
ADMINISTRATOR.BUILD_TABLE - Calling stored procedure.
ADMINISTRATOR.BUILD_TABLE - The value(s) of the input parameters:
TABLE_NAME_SUFFIX = 00
[IBM][CLI Driver][DB2/NT] SQL0007N The character "\" following "IMPORT FROM d:" is not valid. SQLSTATE=42601
ADMINISTRATOR.BUILD_TABLE - Changes rolled back.
ADMINISTRATOR.BUILD_TABLE - Done calling stored procedure.
If I change to forward slashes (ie '/'), then execution gives me the following:
-- Import the data into the seed table
SET stmt = 'IMPORT FROM d:/event00.del OF DEL MESSAGES importmsgs.txt INSERT INTO ' || table_n;
PREPARE s2 FROM stmt;
EXECUTE s2;
----------------
ADMINISTRATOR.BUILD_TABLE - Calling stored procedure.
ADMINISTRATOR.BUILD_TABLE - The value(s) of the input parameters:
TABLE_NAME_SUFFIX = 00
[IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "MESSAGES" was found following ":/event00.del OF DEL". Expected tokens may include: ".". SQLSTATE=42601
ADMINISTRATOR.BUILD_TABLE - Changes rolled back.
ADMINISTRATOR.BUILD_TABLE - Done calling stored procedure.
Any help appreciated.
Here is essentially what I am trying to do:
-- Import the data into the seed table
SET stmt = 'IMPORT FROM d:\event00.del OF DEL MESSAGES importmsgs.txt INSERT INTO ' || table_n;
PREPARE s2 FROM stmt;
EXECUTE s2;
But upon execution, the spb gives me the following:
ADMINISTRATOR.BUILD_TABLE - Calling stored procedure.
ADMINISTRATOR.BUILD_TABLE - The value(s) of the input parameters:
TABLE_NAME_SUFFIX = 00
[IBM][CLI Driver][DB2/NT] SQL0007N The character "\" following "IMPORT FROM d:" is not valid. SQLSTATE=42601
ADMINISTRATOR.BUILD_TABLE - Changes rolled back.
ADMINISTRATOR.BUILD_TABLE - Done calling stored procedure.
If I change to forward slashes (ie '/'), then execution gives me the following:
-- Import the data into the seed table
SET stmt = 'IMPORT FROM d:/event00.del OF DEL MESSAGES importmsgs.txt INSERT INTO ' || table_n;
PREPARE s2 FROM stmt;
EXECUTE s2;
----------------
ADMINISTRATOR.BUILD_TABLE - Calling stored procedure.
ADMINISTRATOR.BUILD_TABLE - The value(s) of the input parameters:
TABLE_NAME_SUFFIX = 00
[IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "MESSAGES" was found following ":/event00.del OF DEL". Expected tokens may include: ".". SQLSTATE=42601
ADMINISTRATOR.BUILD_TABLE - Changes rolled back.
ADMINISTRATOR.BUILD_TABLE - Done calling stored procedure.
Any help appreciated.