Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2013
    Posts
    24

    Unanswered: Load utility to Load Table from Table

    Following is embedded in my UNIX script, and runs well till Load command starts then I get error. Any hint what is wrong? I am trying to Load join result from Select to a Temp Table using Load utility. This new Staging table is empty, hence using Load ductility to Load.

    /* following is for select that is successful */
    DB20000I The SQL command completed successfully.

    /*Error */
    LOAD FROM CR1 OF CURSOR MESSAGES /home/temp/logs.txt TEMPFILES PATH INSERT INTO Target_Table (col1,col2) NONRECOVERABLE

    SQL0104N An unexpected token "INTO" was found following "INSERT". Expected tokens may include: "INSERT". SQLSTATE=42601





    DECLARE CR1 CURSOR for
    SELECT s1.col1
    ,s1.col2

    FROM Source_Table1 s

    INNER JOIN

    Ref_Table r
    ON r.col1 = s1.col1
    WHERE r.col3 = 'Y'

    UNION

    SELECT s1.col1
    ,s1.col2

    FROM Source_Table1 s

    INNER JOIN

    Ref_Table r
    ON r.col1 = s1.col1
    WHERE r.col4 = 'Y'
    ;

    LOAD FROM CR1 OF CURSOR
    MESSAGES ${WK_DIR}${WK_LOG_DIR}/logs.txt
    TEMPFILES PATH ${TEMP_FILE}
    INSERT INTO Target_Table (col1,col2)
    NONRECOVERABLE

    ;

  2. #2
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    LOAD FROM CR1 OF CURSOR MESSAGES /home/temp/logs.txt TEMPFILES PATH INSERT INTO Target_Table (col1,col2) NONRECOVERABLE
    Your syntax is not valid, possibly due to the ${TEMP_FILE} variable being undefined in your script.

    You can avoid such mistake by making your scripts more robust - preventing unitialized variables (using the features of whatever shell you are using). For example in Korn shell use either 'set -u' and/or testing for unitialised variables explicitly.

  3. #3
    Join Date
    Jul 2013
    Posts
    24
    Culprit was incorrect TEMP FILES path name but error pointed to INSERT confused me. Now it is working like a charm. Thank you for pointing it out.

Posting Permissions

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