Results 1 to 2 of 2
  1. #1
    Join Date
    May 2008
    Posts
    39

    Unanswered: Procedure and Load Utility

    Hi

    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)
    )
    LANGUAGE SQL
    BEGIN
    LOAD FROM file_name OF DEL MODIFIED
    BY PAGEFREESPACE=1 NOHEADER USEDEFAULTS
    INSERT INTO table_name;
    END
    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.

    Thanks

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •