PL/I

PL/I

PL/I

 View Only
Expand all | Collapse all

PL/I & DB2: named consts for sqlcodes?

  • 1.  PL/I & DB2: named consts for sqlcodes?

    Posted Tue November 22, 2016 08:28 AM

    Hi all,

    I just read some code where the "sqlcode" from DB2 was handled individually (0, 100, -502, ...). 

    Shouldn't there be some named consts for those sqlcodes (ok, not_found, duplicate_key, ...)?

    Has anybody done that? Pros and cons? Just want to avoid creating named consts but a) they already exist b) there are pitfalls.

    br woecki

    Edit: to make my question clearer:

    Instead of 

    exec sql ...
    select(sqlca.sqlcode);
      when(100) ...
      when(0) ...

    i'd like to write 

    exec sql ...
    select(sqlca.sqlcode);
      when(emtpy) ...
      when(ok) ...

    well, ok, the difference is minimal but i would like it anyway ...

    woecki


  • 2.  Re: PL/I & DB2: named consts for sqlcodes?

    Posted Wed November 23, 2016 03:20 AM

    I did a macro years ago called "Check_SQL_Code" and that one sets a code like you mention but also call a ABEND routine if the SQL-code are non recoverable to ensure a nice log it is always called with a text and every program we have already have a constant for programname. This way it is simple to handle and a log will tell where and what went wrong.

    PeterOL