Thread: Procedure and Load Utility
05-15-08, 02:34 #1Registered User
- Join Date
- May 2008
Unanswered: Procedure and Load Utility
I have created below procedure.My requirement is to parameterize filename and table into which load happens.
CREATE PROCEDURE "x"."Load_table"
(IN "file_name" VARCHAR(200),
IN "table_name" VARCHAR(100)
LOAD FROM file_name OF DEL MODIFIED
BY PAGEFREESPACE=1 NOHEADER USEDEFAULTS
INSERT INTO table_name;
But I get the error
SQL0104N An unexpected token "LOAD" was found following "NGUAGE SQL BEGIN ". Expected tokens may include: "LOOP". LINE NUMBER=7. SQLSTATE=42601
Statement processed with ERROR.
05-15-08, 02:56 #2Registered User
- Join Date
- Jan 2007
- Jena, Germany
LOAD is a DB2 command and not a SQL statement. Thus, you cannot use it like you did in a stored procedure body. But have a look at the ADMIN_CMD procedure.
Parameterizing something like that is done by constructing a string containing the statement and then executing the string with the EXECUTE IMMEDIATE or in case of queries via a prepared statement.Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development