Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2014
    Posts
    294

    Unanswered: SQLSTATE=25001 error on the first call statement

    Hi,

    I have written some coding on db2 c express windows on one system. After that I have taken the backup & restored on other machine.From the second machine, if am trying to call a procedure.Which is giving me the below error;

    db2 => call SP_proc1('MGGHL','QRYYOQY','TUET',1000);
    SQL0428N The SQL statement is only allowed as the first statement in a unit
    of work. SQLSTATE=25001


    Can some one please let me know , what is this about?

  2. #2
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    Follow the directions in the explanation you get from this command:
    db2 "? SQL0428N"
    also visible in the on-line knowledge centre for your version of db2 and operating-system.

  3. #3
    Join Date
    Oct 2002
    Posts
    15
    The only time I ever saw that error was from a 'TRUNCATE' statement, it needs to be surrounded by commits, before and after.

  4. #4
    Join Date
    Jul 2014
    Posts
    294
    i tried all the ways how i can but, not able to solve the issue.

    CREATE OR REPLACE PROCEDURE proc1 (IN pl VARCHAR(10),IN it VARCHAR(10), IN pi VARCHAR(20),IN yu INTEGER)
    DYNAMIC RESULT SETS 1
    P1: BEGIN

    COMMIT;
    EXECUTE IMMEDIATE 'DELETE FROM JREO';
    COMMIT;

    CALL Q298080();

    CALL WIUTYI(WIUYT,WYTIO,IUEYT,ERT);

    END P1

    so i am posting my code. can some one help me with this

  5. #5
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    You need to determine which statement is causing the the issue. It is not necessarily in the proc1 Stored Procedure. It could be in one of the embedded Stored Procedures.

    Andy

  6. #6
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    Every one of your sprocs should catch exceptions, and report the details (for example into a table or dbms_output)
    So each sproc should have a 'declare exit handler for sqlexception' which includes a 'get diagnostics exception...' and then report the results, and then use 'signal sqlstate...' to throw the exception to the caller.

    That will make it easier to find programming errors.

Tags for this Thread

Posting Permissions

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