Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2004
    Posts
    3

    Unanswered: sql 100 warnings in sqlj

    I'm trying to capture SQL 100 warnings with SQLJ. I've tried both of the below methods:

    SQLWarning sqlw = getConnectContext().getConnection().getWarnings();

    SQLwarning sqlw = getConnectContext().getExecutionContext().getWarni ngs();

    which return null.


    Warnings are correctly returned in the JDBC environment with this statement:

    SQLWarning sqlw = stmt.getWarnings();


    Were using version 8.1.3. Is there something I'm missing in my SQLJ environment?

  2. #2
    Join Date
    Mar 2004
    Location
    Toronto, ON, Canada
    Posts
    513
    This ConnectionContext / ExecutionContext stuff can get pretty hairy.

    Are you explicitly specifying which context to use on the statement?

    ie. #sql [ctx, ectx] { SELECT ... }

    then do ectx.getWarnings()?

    I'm not sure if it works if you're just using the default.
    --
    Jonathan Petruk
    DB2 Database Consultant

  3. #3
    Join Date
    Apr 2004
    Posts
    3
    I was not explicitly setting the context, but I am now with the same results - SQLWarning is returning as null.

  4. #4
    Join Date
    Mar 2004
    Location
    Toronto, ON, Canada
    Posts
    513
    Originally posted by zarnold
    I was not explicitly setting the context, but I am now with the same results - SQLWarning is returning as null.
    I'm out of ideas, it really should be populated if the statement is generating a warning, perhaps a call to IBM support is in order.
    --
    Jonathan Petruk
    DB2 Database Consultant

  5. #5
    Join Date
    Apr 2004
    Posts
    3

    SQL 100 Warnings

    IBM says that the driver is working as implemented and that no warnings are generated on a update when rows are not found.

    The work around is to check the numer of rows updated with something like this:

    getConnectContext().getExecutionContext().getUpdat eCount();

  6. #6
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    That propably only works for insert, update, or delete statements. DB2 provides the following information in the SQLCA data item sqlerrd(3), which I assume is where getUpdateCount() comes from.

    If PREPARE is invoked and successful, contains an estimate of the number of rows that will be returned. After INSERT, UPDATE, and DELETE, contains the actual number of rows that qualified for the operation. If compound SQL is invoked, contains an accumulation of all sub-statement rows. If CONNECT is invoked, contains 1 if the database can be updated; 2 if the database is read only.

    If CREATE PROCEDURE for an SQL procedure is invoked and an error is encountered parsing the SQL procedure body, contains the line number where the error was encountered. The sixth byte of sqlcaid must be L for this to be a valid line number.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

Posting Permissions

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