DB2 Execute Immediate

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nghivo
    New Member
    • Apr 2007
    • 17

    #1

    DB2 Execute Immediate

    My environment
    DB2 9.1.4 on Sun OS

    I write a C embedded SQL to load data.

    I declare host vars as:
    EXEC SQL BEGIN DECLARE SECTION;
    SQL TYPE IS CLOB(599999) sqlStr;
    EXEC SQL END DECLARE SECTION;

    then set sqlStr and execute sqlStr as

    sprintf(sqlStr. data, "%s, %d, %d, '%s')", staticStr, recId, seqno, data);
    sqlStr.length = strlen(sqlStr.d ata);
    EXEC SQL EXECUTE IMMEDIATE :sqlStr;

    my staticStr contains table name, column names in run time and "data" can contains very long string. "data" is also inserted into a clob column in the table specified inside staticStr.

    The compilation is OK but in execution I get this error:

    EXECUTE IMMEDIATE ERROR: SQLCODE: -805 SQLSTATE 51002: The package corresponding to an SQL statement execution request
    was not found.

    Does this mean I am missing a DB2 library in during compilation ??
    I check and -805 means "The DBRM or package name not found in plan"

    What does this mean ????
    Please help. Thanks
  • nghivo
    New Member
    • Apr 2007
    • 17

    #2
    I figured it out. It has something to do with the BIND process.
    To solve the problem, deverlopers have to make sure that:

    1. the makefile points to the right database.
    2. correct db id/ password uses to connect to database during compilation.
    3. in C code, the EXEC SQL CONNECT must also have the USER id USING pwd portion.

    That will solve the mysterious -805 and 51002 code.
    Please correct if I am wrong

    Comment

    • sakumar9
      Recognized Expert New Member
      • Jan 2008
      • 127

      #3
      I am not sure if you have binded the package. (this is what the error says).
      After precompilation, there will be one *.bnd file. You need to bind this package with DB2. You can use "db2 BIND <bindfilename.b nd>" command to bind the package.


      Let me know if you still have this error,


      Regards
      -- Sanjay

      Comment

      • nghivo
        New Member
        • Apr 2007
        • 17

        #4
        I did bind but bound to the wrong objects. The error message is quite ambiguous.
        Everything is all right now.

        Comment

        Working...