Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    20

    Question Unanswered: V8 WinNT: Compiling recursive stored procedures

    Hi All,

    I am running db2 V 8 on Windows NT. How can I compile a function/stored procedure that contains recursive call? I scanned the archives and found that the recursive call can be deferred untill runtime using execute immediate. But when I tried:

    CREATE PROCEDURE ADMINISTRATOR.PROCEDURE1 ( )
    ------------------------------------------------------------------------
    -- SQL Stored Procedure
    ------------------------------------------------------------------------
    P1: BEGIN
    execute immediate "call procedure1()";
    END P1

    the compiler said:
    ADMINISTRATOR.PROCEDURE1: 9: [IBM][CLI Driver][DB2/NT] SQL0113N "call procedure1()" contains a character that is not allowed or does not contain any characters. LINE NUMBER=9. SQLSTATE=42601

    What's the problem....

    Thanks and Regards
    Deepak Ajmera

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Deepak,
    Try it this way:

    DECLARE stmt varchar(200);

    SET stmt = 'CALL mySchema.MyProc(?,?)';

    execute stmt into outVar1, out var2 using invar1, invar2;

    The samples in the "SQL Reference" and the "DB2 SQL Procedural Language for Linux, UNIX, and Windows" book do it this way.

    HTH

    Andy

Posting Permissions

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