Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

USING IMPORT IN STORED PROCEDURE, PREPARE EXEC PROBLEM

Status
Not open for further replies.

michaelthegriff

Programmer
Sep 17, 2002
1
US
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top