Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Posts
    16

    Unanswered: executeUpdate does not return row count when using db2 stored procedures...

    Hi,
    I am executing a stored procedure through callablestatement's 'executeUpdate'. According to JDK this should return the number of records updated. This is not true for stored procedure invokation. Is there anyway, I can determine the number of records affected for an update or insert within the stored procedure. By this way, I would be able to register an out parameter and get the update count.
    Thanks
    Selva

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: executeUpdate does not return row count when using db2 stored procedures...

    The SQLCA's ERRD(3) will have the number of rows updated, if you read this location immediately following the update ...

    But, I am not sure how to get his insdie the stored proc ?

    Just wondering if someone here has tried to use SQLCA in their stored procs

    HTH

    Sathyaram

    Originally posted by sselvakumar72
    Hi,
    I am executing a stored procedure through callablestatement's 'executeUpdate'. According to JDK this should return the number of records updated. This is not true for stored procedure invokation. Is there anyway, I can determine the number of records affected for an update or insert within the stored procedure. By this way, I would be able to register an out parameter and get the update count.
    Thanks
    Selva
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    37

    Re: executeUpdate does not return row count when using db2 stored procedures...

    Hi Selva,

    The DB2 JDBC drivers (v 5, 6, 7) do not support a surprising number of JDBC methods. Attached is a list. Probably, you need to do some logic magic to get the number of updated rows back to the client as the driver will not do that. It only returns a -2 if any rows updated.

    Cheers,

    Julius
    Attached Files Attached Files

  4. #4
    Join Date
    May 2003
    Posts
    16
    The only way, I could figure out the way to get the number of rows affected by a SQl inside a stored procedure (DB2) is :

    1. Define an out parameter, say -

    CREATE PROCEDURE procedure_name(OUT out_val BIGINT)

    2. After the SQL, add the following stmt

    GET DIAGONOSTICS procedure_name.out_val = ROW_COUNT;

    The ROW_COUNT variable has the number of rows affected value.

    Hope this is usefull.
    Selva Kumar

Posting Permissions

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