How to decipher a SQLCODE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Twan Kennis

    How to decipher a SQLCODE

    Hi,

    I have a DB2 database on the IBM iSeries platform, on which I created
    several Stored Procedures with the SQLCODE as a return-parameter.
    These Stored Procedures are called from a Windows application (build in
    Visual Basic) using an ADO/OLE DB Provider on a IBM Client Access ODBC
    driver.

    On the Internet I found a whitepaper "SQL messages and codes" provided
    by IBM which describes a complete list of all SQLSTATEs, SQLCODEs and
    their corresponding translation.

    They say all SQL-codes and messages are stored in the QSQLMSG-file, and
    to translate a SQLCODE (i.e. SQLCODE -204), I have to execute the
    following command from the iSeries commandline:
    [color=blue][color=green]
    >> DSPMSGD RANGE(SQL0204) MSGF(QSQLMSG)[/color][/color]

    Question is, how can I decipher my SQLcode from my windows application?
    i.e. with a SQL-command (????) like:
    select * from qsys2.qsqlmsg where code = 'SQL0204'

    Thanks for your help.

    Twan Kennis
    SKB Vragenlijst Services
    Amsterdam, The Netherlands




  • Larry Menard

    #2
    Re: How to decipher a SQLCODE

    Just enter "db2 ? <sqlcode>", as in:


    C:\>db2 ? sql0104


    SQL0104N An unexpected token "<token>" was found following
    "<text>". Expected tokens may include:
    "<token-list>".

    Explanation:

    A syntax error in the SQL statement or the input command string
    for the SYSPROC.ADMIN_C MD procedure was detected at the specified
    token following the text "<text>". The "<text>" field indicates
    the 20 characters of the SQL statement or the input command
    string for the SYSPROC.ADMIN_C MD procedure that preceded the
    token that is not valid.

    As an aid, a partial list of valid tokens is provided in the
    SQLERRM field of the SQLCA as "<token-list>". This list assumes
    the statement is correct to that point.

    The statement cannot be processed.

    User Response:

    Examine and correct the statement in the area of the specified
    token.

    sqlcode : -104

    sqlstate : 42601

    --
    --------------------
    Larry Menard
    "Defender of Geese and of All Things Natural"


    "Twan Kennis" <computer@skb.n l> wrote in message
    news:11lrubilcv tp952@corp.supe rnews.com...[color=blue]
    > Hi,
    >
    > I have a DB2 database on the IBM iSeries platform, on which I created
    > several Stored Procedures with the SQLCODE as a return-parameter.
    > These Stored Procedures are called from a Windows application (build in
    > Visual Basic) using an ADO/OLE DB Provider on a IBM Client Access ODBC
    > driver.
    >
    > On the Internet I found a whitepaper "SQL messages and codes" provided
    > by IBM which describes a complete list of all SQLSTATEs, SQLCODEs and
    > their corresponding translation.
    >
    > They say all SQL-codes and messages are stored in the QSQLMSG-file, and
    > to translate a SQLCODE (i.e. SQLCODE -204), I have to execute the
    > following command from the iSeries commandline:
    >[color=green][color=darkred]
    >>> DSPMSGD RANGE(SQL0204) MSGF(QSQLMSG)[/color][/color]
    >
    > Question is, how can I decipher my SQLcode from my windows application?
    > i.e. with a SQL-command (????) like:
    > select * from qsys2.qsqlmsg where code = 'SQL0204'
    >
    > Thanks for your help.
    >
    > Twan Kennis
    > SKB Vragenlijst Services
    > Amsterdam, The Netherlands
    >
    >
    >
    >[/color]


    Comment

    • Rhino

      #3
      Re: How to decipher a SQLCODE

      Does that work on ISeries? Remember, he is using AS/400, not DB2 for
      Linux/unix/windows.

      Unfortunately, I don't know nearly enough to answer this question for DB2 on
      AS/400 and there are not a lot of AS/400 users lurking on this newsgroup....

      Rhino

      "Larry Menard" <root@GoSpamYou rself.com> wrote in message
      news:IbCdndKa6t-axMPeRVn-sQ@rogers.com.. .[color=blue]
      > Just enter "db2 ? <sqlcode>", as in:
      >
      >
      > C:\>db2 ? sql0104
      >
      >
      > SQL0104N An unexpected token "<token>" was found following
      > "<text>". Expected tokens may include:
      > "<token-list>".
      >
      > Explanation:
      >
      > A syntax error in the SQL statement or the input command string
      > for the SYSPROC.ADMIN_C MD procedure was detected at the specified
      > token following the text "<text>". The "<text>" field indicates
      > the 20 characters of the SQL statement or the input command
      > string for the SYSPROC.ADMIN_C MD procedure that preceded the
      > token that is not valid.
      >
      > As an aid, a partial list of valid tokens is provided in the
      > SQLERRM field of the SQLCA as "<token-list>". This list assumes
      > the statement is correct to that point.
      >
      > The statement cannot be processed.
      >
      > User Response:
      >
      > Examine and correct the statement in the area of the specified
      > token.
      >
      > sqlcode : -104
      >
      > sqlstate : 42601
      >
      > --
      > --------------------
      > Larry Menard
      > "Defender of Geese and of All Things Natural"
      >
      >
      > "Twan Kennis" <computer@skb.n l> wrote in message
      > news:11lrubilcv tp952@corp.supe rnews.com...[color=green]
      > > Hi,
      > >
      > > I have a DB2 database on the IBM iSeries platform, on which I created
      > > several Stored Procedures with the SQLCODE as a return-parameter.
      > > These Stored Procedures are called from a Windows application (build in
      > > Visual Basic) using an ADO/OLE DB Provider on a IBM Client Access ODBC
      > > driver.
      > >
      > > On the Internet I found a whitepaper "SQL messages and codes" provided
      > > by IBM which describes a complete list of all SQLSTATEs, SQLCODEs and
      > > their corresponding translation.
      > >
      > > They say all SQL-codes and messages are stored in the QSQLMSG-file, and
      > > to translate a SQLCODE (i.e. SQLCODE -204), I have to execute the
      > > following command from the iSeries commandline:
      > >[color=darkred]
      > >>> DSPMSGD RANGE(SQL0204) MSGF(QSQLMSG)[/color]
      > >
      > > Question is, how can I decipher my SQLcode from my windows application?
      > > i.e. with a SQL-command (????) like:
      > > select * from qsys2.qsqlmsg where code = 'SQL0204'
      > >
      > > Thanks for your help.
      > >
      > > Twan Kennis
      > > SKB Vragenlijst Services
      > > Amsterdam, The Netherlands
      > >
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Larry Menard

        #4
        Re: How to decipher a SQLCODE

        Hey, Rhino.

        The server is iSeries, but the application is running on Windows. The
        sqlcode being reported at the client app should be queried on the client
        platform.
        --
        --------------------
        Larry Menard
        "Defender of Geese and of All Things Natural"


        "Rhino" <no.offline.con tact.please@nos pam.com> wrote in message
        news:Pty7f.7544 $Nj3.605490@new s20.bellglobal. com...[color=blue]
        > Does that work on ISeries? Remember, he is using AS/400, not DB2 for
        > Linux/unix/windows.
        >
        > Unfortunately, I don't know nearly enough to answer this question for DB2
        > on
        > AS/400 and there are not a lot of AS/400 users lurking on this
        > newsgroup....
        >
        > Rhino
        >
        > "Larry Menard" <root@GoSpamYou rself.com> wrote in message
        > news:IbCdndKa6t-axMPeRVn-sQ@rogers.com.. .[color=green]
        >> Just enter "db2 ? <sqlcode>", as in:
        >>
        >>
        >> C:\>db2 ? sql0104
        >>
        >>
        >> SQL0104N An unexpected token "<token>" was found following
        >> "<text>". Expected tokens may include:
        >> "<token-list>".
        >>
        >> Explanation:
        >>
        >> A syntax error in the SQL statement or the input command string
        >> for the SYSPROC.ADMIN_C MD procedure was detected at the specified
        >> token following the text "<text>". The "<text>" field indicates
        >> the 20 characters of the SQL statement or the input command
        >> string for the SYSPROC.ADMIN_C MD procedure that preceded the
        >> token that is not valid.
        >>
        >> As an aid, a partial list of valid tokens is provided in the
        >> SQLERRM field of the SQLCA as "<token-list>". This list assumes
        >> the statement is correct to that point.
        >>
        >> The statement cannot be processed.
        >>
        >> User Response:
        >>
        >> Examine and correct the statement in the area of the specified
        >> token.
        >>
        >> sqlcode : -104
        >>
        >> sqlstate : 42601
        >>
        >> --
        >> --------------------
        >> Larry Menard
        >> "Defender of Geese and of All Things Natural"
        >>
        >>
        >> "Twan Kennis" <computer@skb.n l> wrote in message
        >> news:11lrubilcv tp952@corp.supe rnews.com...[color=darkred]
        >> > Hi,
        >> >
        >> > I have a DB2 database on the IBM iSeries platform, on which I created
        >> > several Stored Procedures with the SQLCODE as a return-parameter.
        >> > These Stored Procedures are called from a Windows application (build in
        >> > Visual Basic) using an ADO/OLE DB Provider on a IBM Client Access ODBC
        >> > driver.
        >> >
        >> > On the Internet I found a whitepaper "SQL messages and codes" provided
        >> > by IBM which describes a complete list of all SQLSTATEs, SQLCODEs and
        >> > their corresponding translation.
        >> >
        >> > They say all SQL-codes and messages are stored in the QSQLMSG-file, and
        >> > to translate a SQLCODE (i.e. SQLCODE -204), I have to execute the
        >> > following command from the iSeries commandline:
        >> >
        >> >>> DSPMSGD RANGE(SQL0204) MSGF(QSQLMSG)
        >> >
        >> > Question is, how can I decipher my SQLcode from my windows application?
        >> > i.e. with a SQL-command (????) like:
        >> > select * from qsys2.qsqlmsg where code = 'SQL0204'
        >> >
        >> > Thanks for your help.
        >> >
        >> > Twan Kennis
        >> > SKB Vragenlijst Services
        >> > Amsterdam, The Netherlands
        >> >
        >> >
        >> >
        >> >[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Rhino

          #5
          Re: How to decipher a SQLCODE

          Hi Larry,

          I've never tried accessing an AS/400 from a Windows client. It occurred to
          me that an SQLCode sent by an AS/400 might be one that is unique to AS/400
          and I wasn't sure if a Windows client would know what to do with those.
          Therefore, it seemed safer to query the AS/400 directly. But, now that I
          reread the original post, I see that the code is SQL0204 which is present in
          DB2 for Linux/Unix/Windows and OS/390. I *assume* it has the same meaning on
          AS/400 as it does on those other platforms. So, it doesn't much matter which
          platform's manuals (or command line tool) he uses since it should give
          approximately the same answer.

          I still wonder what would happen if he specified a 'db2 ? sqlnnnn' if 'nnnn'
          was unique to the platform where the data originated and did *not* occur on
          the client. Oh well, one of these days I suppose I'll bump into that for
          myself :-)

          Rhino

          "Larry Menard" <root@GoSpamYou rself.com> wrote in message
          news:Q4KdneDwmP cgI8PeRVn-ug@rogers.com.. .[color=blue]
          > Hey, Rhino.
          >
          > The server is iSeries, but the application is running on Windows. The
          > sqlcode being reported at the client app should be queried on the client
          > platform.
          > --
          > --------------------
          > Larry Menard
          > "Defender of Geese and of All Things Natural"
          >
          >
          > "Rhino" <no.offline.con tact.please@nos pam.com> wrote in message
          > news:Pty7f.7544 $Nj3.605490@new s20.bellglobal. com...[color=green]
          > > Does that work on ISeries? Remember, he is using AS/400, not DB2 for
          > > Linux/unix/windows.
          > >
          > > Unfortunately, I don't know nearly enough to answer this question for[/color][/color]
          DB2[color=blue][color=green]
          > > on
          > > AS/400 and there are not a lot of AS/400 users lurking on this
          > > newsgroup....
          > >
          > > Rhino
          > >
          > > "Larry Menard" <root@GoSpamYou rself.com> wrote in message
          > > news:IbCdndKa6t-axMPeRVn-sQ@rogers.com.. .[color=darkred]
          > >> Just enter "db2 ? <sqlcode>", as in:
          > >>
          > >>
          > >> C:\>db2 ? sql0104
          > >>
          > >>
          > >> SQL0104N An unexpected token "<token>" was found following
          > >> "<text>". Expected tokens may include:
          > >> "<token-list>".
          > >>
          > >> Explanation:
          > >>
          > >> A syntax error in the SQL statement or the input command string
          > >> for the SYSPROC.ADMIN_C MD procedure was detected at the specified
          > >> token following the text "<text>". The "<text>" field indicates
          > >> the 20 characters of the SQL statement or the input command
          > >> string for the SYSPROC.ADMIN_C MD procedure that preceded the
          > >> token that is not valid.
          > >>
          > >> As an aid, a partial list of valid tokens is provided in the
          > >> SQLERRM field of the SQLCA as "<token-list>". This list assumes
          > >> the statement is correct to that point.
          > >>
          > >> The statement cannot be processed.
          > >>
          > >> User Response:
          > >>
          > >> Examine and correct the statement in the area of the specified
          > >> token.
          > >>
          > >> sqlcode : -104
          > >>
          > >> sqlstate : 42601
          > >>
          > >> --
          > >> --------------------
          > >> Larry Menard
          > >> "Defender of Geese and of All Things Natural"
          > >>
          > >>
          > >> "Twan Kennis" <computer@skb.n l> wrote in message
          > >> news:11lrubilcv tp952@corp.supe rnews.com...
          > >> > Hi,
          > >> >
          > >> > I have a DB2 database on the IBM iSeries platform, on which I created
          > >> > several Stored Procedures with the SQLCODE as a return-parameter.
          > >> > These Stored Procedures are called from a Windows application (build[/color][/color][/color]
          in[color=blue][color=green][color=darkred]
          > >> > Visual Basic) using an ADO/OLE DB Provider on a IBM Client Access[/color][/color][/color]
          ODBC[color=blue][color=green][color=darkred]
          > >> > driver.
          > >> >
          > >> > On the Internet I found a whitepaper "SQL messages and codes"[/color][/color][/color]
          provided[color=blue][color=green][color=darkred]
          > >> > by IBM which describes a complete list of all SQLSTATEs, SQLCODEs and
          > >> > their corresponding translation.
          > >> >
          > >> > They say all SQL-codes and messages are stored in the QSQLMSG-file,[/color][/color][/color]
          and[color=blue][color=green][color=darkred]
          > >> > to translate a SQLCODE (i.e. SQLCODE -204), I have to execute the
          > >> > following command from the iSeries commandline:
          > >> >
          > >> >>> DSPMSGD RANGE(SQL0204) MSGF(QSQLMSG)
          > >> >
          > >> > Question is, how can I decipher my SQLcode from my windows[/color][/color][/color]
          application?[color=blue][color=green][color=darkred]
          > >> > i.e. with a SQL-command (????) like:
          > >> > select * from qsys2.qsqlmsg where code = 'SQL0204'
          > >> >
          > >> > Thanks for your help.
          > >> >
          > >> > Twan Kennis
          > >> > SKB Vragenlijst Services
          > >> > Amsterdam, The Netherlands
          > >> >
          > >> >
          > >> >
          > >> >
          > >>
          > >>[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Karl Hanson

            #6
            Re: How to decipher a SQLCODE

            Rhino wrote:[color=blue]
            > Hi Larry,
            >
            > I've never tried accessing an AS/400 from a Windows client. It occurred to
            > me that an SQLCode sent by an AS/400 might be one that is unique to AS/400
            > and I wasn't sure if a Windows client would know what to do with those.
            > Therefore, it seemed safer to query the AS/400 directly. But, now that I
            > reread the original post, I see that the code is SQL0204 which is present in
            > DB2 for Linux/Unix/Windows and OS/390. I *assume* it has the same meaning on
            > AS/400 as it does on those other platforms. So, it doesn't much matter which
            > platform's manuals (or command line tool) he uses since it should give
            > approximately the same answer.
            >
            > I still wonder what would happen if he specified a 'db2 ? sqlnnnn' if 'nnnn'
            > was unique to the platform where the data originated and did *not* occur on
            > the client. Oh well, one of these days I suppose I'll bump into that for
            > myself :-)
            >
            > Rhino
            >
            > "Larry Menard" <root@GoSpamYou rself.com> wrote in message
            > news:Q4KdneDwmP cgI8PeRVn-ug@rogers.com.. .
            >[color=green]
            >> Hey, Rhino.
            >>
            >> The server is iSeries, but the application is running on Windows. The
            >>sqlcode being reported at the client app should be queried on the client
            >>platform.
            >>--
            >>--------------------
            >>Larry Menard
            >>"Defender of Geese and of All Things Natural"
            >>[/color][/color]

            One misconception might be the assumption that the container of iSeries
            messages corresponding to SQLCODEs is an SQL table:
            [color=blue]
            > Question is, how can I decipher my SQLcode from my windows application?
            > i.e. with a SQL-command (????) like:
            > select * from qsys2.qsqlmsg where code = 'SQL0204'[/color]

            This is not possible (directly), because messages are stored in an
            OS/400 Message File (*MSGF) object, which is *not* an SQL table.

            If connected via an iSeries Access (aka Client Access) ODBC driver,
            there would normally be a QZDASOINIT job running on iSeries to process
            SQL requests from the client. It should be possible to locate this job
            < eg OS/400 command: wrkactjob job(qzda*) > and see the SQL0204 message
            in the job log.

            --
            Karl Hanson

            Comment

            • Larry Menard

              #7
              Re: How to decipher a SQLCODE

              There is a table of SQLCODEs that don't map across platforms, so by the
              time an SQLCODE is reported at the client, it should have already undergone
              any translation necessary. For example if SQLCODE "1234" on the iSeries
              corresponds to SQLCODE "5678" on LUW, the app will report it as "5678".

              I suppose there might be cases of SQLCODEs that are truly
              platform-specific (no equivalent on other platforms). Not sure what would
              happen in that case, but I'm sure it's a rare case.
              --
              --------------------
              Larry Menard
              "Defender of Geese and of All Things Natural"


              "Rhino" <no.offline.con tact.please@nos pam.com> wrote in message
              news:q0M7f.6075 $ki7.364452@new s20.bellglobal. com...[color=blue]
              > Hi Larry,
              >
              > I've never tried accessing an AS/400 from a Windows client. It occurred to
              > me that an SQLCode sent by an AS/400 might be one that is unique to AS/400
              > and I wasn't sure if a Windows client would know what to do with those.
              > Therefore, it seemed safer to query the AS/400 directly. But, now that I
              > reread the original post, I see that the code is SQL0204 which is present
              > in
              > DB2 for Linux/Unix/Windows and OS/390. I *assume* it has the same meaning
              > on
              > AS/400 as it does on those other platforms. So, it doesn't much matter
              > which
              > platform's manuals (or command line tool) he uses since it should give
              > approximately the same answer.
              >
              > I still wonder what would happen if he specified a 'db2 ? sqlnnnn' if
              > 'nnnn'
              > was unique to the platform where the data originated and did *not* occur
              > on
              > the client. Oh well, one of these days I suppose I'll bump into that for
              > myself :-)
              >
              > Rhino
              >
              > "Larry Menard" <root@GoSpamYou rself.com> wrote in message
              > news:Q4KdneDwmP cgI8PeRVn-ug@rogers.com.. .[color=green]
              >> Hey, Rhino.
              >>
              >> The server is iSeries, but the application is running on Windows. The
              >> sqlcode being reported at the client app should be queried on the client
              >> platform.
              >> --
              >> --------------------
              >> Larry Menard
              >> "Defender of Geese and of All Things Natural"
              >>
              >>
              >> "Rhino" <no.offline.con tact.please@nos pam.com> wrote in message
              >> news:Pty7f.7544 $Nj3.605490@new s20.bellglobal. com...[color=darkred]
              >> > Does that work on ISeries? Remember, he is using AS/400, not DB2 for
              >> > Linux/unix/windows.
              >> >
              >> > Unfortunately, I don't know nearly enough to answer this question for[/color][/color]
              > DB2[color=green][color=darkred]
              >> > on
              >> > AS/400 and there are not a lot of AS/400 users lurking on this
              >> > newsgroup....
              >> >
              >> > Rhino
              >> >
              >> > "Larry Menard" <root@GoSpamYou rself.com> wrote in message
              >> > news:IbCdndKa6t-axMPeRVn-sQ@rogers.com.. .
              >> >> Just enter "db2 ? <sqlcode>", as in:
              >> >>
              >> >>
              >> >> C:\>db2 ? sql0104
              >> >>
              >> >>
              >> >> SQL0104N An unexpected token "<token>" was found following
              >> >> "<text>". Expected tokens may include:
              >> >> "<token-list>".
              >> >>
              >> >> Explanation:
              >> >>
              >> >> A syntax error in the SQL statement or the input command string
              >> >> for the SYSPROC.ADMIN_C MD procedure was detected at the specified
              >> >> token following the text "<text>". The "<text>" field indicates
              >> >> the 20 characters of the SQL statement or the input command
              >> >> string for the SYSPROC.ADMIN_C MD procedure that preceded the
              >> >> token that is not valid.
              >> >>
              >> >> As an aid, a partial list of valid tokens is provided in the
              >> >> SQLERRM field of the SQLCA as "<token-list>". This list assumes
              >> >> the statement is correct to that point.
              >> >>
              >> >> The statement cannot be processed.
              >> >>
              >> >> User Response:
              >> >>
              >> >> Examine and correct the statement in the area of the specified
              >> >> token.
              >> >>
              >> >> sqlcode : -104
              >> >>
              >> >> sqlstate : 42601
              >> >>
              >> >> --
              >> >> --------------------
              >> >> Larry Menard
              >> >> "Defender of Geese and of All Things Natural"
              >> >>
              >> >>
              >> >> "Twan Kennis" <computer@skb.n l> wrote in message
              >> >> news:11lrubilcv tp952@corp.supe rnews.com...
              >> >> > Hi,
              >> >> >
              >> >> > I have a DB2 database on the IBM iSeries platform, on which I
              >> >> > created
              >> >> > several Stored Procedures with the SQLCODE as a return-parameter.
              >> >> > These Stored Procedures are called from a Windows application (build[/color][/color]
              > in[color=green][color=darkred]
              >> >> > Visual Basic) using an ADO/OLE DB Provider on a IBM Client Access[/color][/color]
              > ODBC[color=green][color=darkred]
              >> >> > driver.
              >> >> >
              >> >> > On the Internet I found a whitepaper "SQL messages and codes"[/color][/color]
              > provided[color=green][color=darkred]
              >> >> > by IBM which describes a complete list of all SQLSTATEs, SQLCODEs
              >> >> > and
              >> >> > their corresponding translation.
              >> >> >
              >> >> > They say all SQL-codes and messages are stored in the QSQLMSG-file,[/color][/color]
              > and[color=green][color=darkred]
              >> >> > to translate a SQLCODE (i.e. SQLCODE -204), I have to execute the
              >> >> > following command from the iSeries commandline:
              >> >> >
              >> >> >>> DSPMSGD RANGE(SQL0204) MSGF(QSQLMSG)
              >> >> >
              >> >> > Question is, how can I decipher my SQLcode from my windows[/color][/color]
              > application?[color=green][color=darkred]
              >> >> > i.e. with a SQL-command (????) like:
              >> >> > select * from qsys2.qsqlmsg where code = 'SQL0204'
              >> >> >
              >> >> > Thanks for your help.
              >> >> >
              >> >> > Twan Kennis
              >> >> > SKB Vragenlijst Services
              >> >> > Amsterdam, The Netherlands
              >> >> >
              >> >> >
              >> >> >
              >> >> >
              >> >>
              >> >>
              >> >
              >> >[/color]
              >>
              >>[/color]
              >
              >[/color]


              Comment

              • Robert

                #8
                Re: How to decipher a SQLCODE

                Surely this is a reason for using SQLSTATE in new developments,
                SQLCODEs were never standardised, while even different vendors should
                use the same SQLSTATEs with perhaps the exception of a few vendor
                variations for rather esoteric circumstances.

                Robert

                Comment

                • Twan Kennis

                  #9
                  Re: How to decipher a SQLCODE

                  Rhino,

                  As a pity, there is no such "db2" commandlinetool available on my
                  workstation. :-(

                  Twan Kennis


                  --
                  Groeten, Twan
                  SKB Vragenlijst Services, automatisering
                  "Rhino" <no.offline.con tact.please@nos pam.com> wrote in message
                  news:q0M7f.6075 $ki7.364452@new s20.bellglobal. com...[color=blue]
                  > Hi Larry,
                  >
                  > I've never tried accessing an AS/400 from a Windows client. It[/color]
                  occurred to[color=blue]
                  > me that an SQLCode sent by an AS/400 might be one that is unique to[/color]
                  AS/400[color=blue]
                  > and I wasn't sure if a Windows client would know what to do with[/color]
                  those.[color=blue]
                  > Therefore, it seemed safer to query the AS/400 directly. But, now that[/color]
                  I[color=blue]
                  > reread the original post, I see that the code is SQL0204 which is[/color]
                  present in[color=blue]
                  > DB2 for Linux/Unix/Windows and OS/390. I *assume* it has the same[/color]
                  meaning on[color=blue]
                  > AS/400 as it does on those other platforms. So, it doesn't much matter[/color]
                  which[color=blue]
                  > platform's manuals (or command line tool) he uses since it should give
                  > approximately the same answer.
                  >
                  > I still wonder what would happen if he specified a 'db2 ? sqlnnnn' if[/color]
                  'nnnn'[color=blue]
                  > was unique to the platform where the data originated and did *not*[/color]
                  occur on[color=blue]
                  > the client. Oh well, one of these days I suppose I'll bump into that[/color]
                  for[color=blue]
                  > myself :-)
                  >
                  > Rhino
                  >
                  > "Larry Menard" <root@GoSpamYou rself.com> wrote in message
                  > news:Q4KdneDwmP cgI8PeRVn-ug@rogers.com.. .[color=green]
                  > > Hey, Rhino.
                  > >
                  > > The server is iSeries, but the application is running on Windows.[/color][/color]
                  The[color=blue][color=green]
                  > > sqlcode being reported at the client app should be queried on the[/color][/color]
                  client[color=blue][color=green]
                  > > platform.
                  > > --
                  > > --------------------
                  > > Larry Menard
                  > > "Defender of Geese and of All Things Natural"
                  > >
                  > >
                  > > "Rhino" <no.offline.con tact.please@nos pam.com> wrote in message
                  > > news:Pty7f.7544 $Nj3.605490@new s20.bellglobal. com...[color=darkred]
                  > > > Does that work on ISeries? Remember, he is using AS/400, not DB2[/color][/color][/color]
                  for[color=blue][color=green][color=darkred]
                  > > > Linux/unix/windows.
                  > > >
                  > > > Unfortunately, I don't know nearly enough to answer this question[/color][/color][/color]
                  for[color=blue]
                  > DB2[color=green][color=darkred]
                  > > > on
                  > > > AS/400 and there are not a lot of AS/400 users lurking on this
                  > > > newsgroup....
                  > > >
                  > > > Rhino
                  > > >
                  > > > "Larry Menard" <root@GoSpamYou rself.com> wrote in message
                  > > > news:IbCdndKa6t-axMPeRVn-sQ@rogers.com.. .
                  > > >> Just enter "db2 ? <sqlcode>", as in:
                  > > >>
                  > > >>
                  > > >> C:\>db2 ? sql0104
                  > > >>
                  > > >>
                  > > >> SQL0104N An unexpected token "<token>" was found following
                  > > >> "<text>". Expected tokens may include:
                  > > >> "<token-list>".
                  > > >>
                  > > >> Explanation:
                  > > >>
                  > > >> A syntax error in the SQL statement or the input command string
                  > > >> for the SYSPROC.ADMIN_C MD procedure was detected at the specified
                  > > >> token following the text "<text>". The "<text>" field indicates
                  > > >> the 20 characters of the SQL statement or the input command
                  > > >> string for the SYSPROC.ADMIN_C MD procedure that preceded the
                  > > >> token that is not valid.
                  > > >>
                  > > >> As an aid, a partial list of valid tokens is provided in the
                  > > >> SQLERRM field of the SQLCA as "<token-list>". This list assumes
                  > > >> the statement is correct to that point.
                  > > >>
                  > > >> The statement cannot be processed.
                  > > >>
                  > > >> User Response:
                  > > >>
                  > > >> Examine and correct the statement in the area of the specified
                  > > >> token.
                  > > >>
                  > > >> sqlcode : -104
                  > > >>
                  > > >> sqlstate : 42601
                  > > >>
                  > > >> --
                  > > >> --------------------
                  > > >> Larry Menard
                  > > >> "Defender of Geese and of All Things Natural"
                  > > >>
                  > > >>
                  > > >> "Twan Kennis" <computer@skb.n l> wrote in message
                  > > >> news:11lrubilcv tp952@corp.supe rnews.com...
                  > > >> > Hi,
                  > > >> >
                  > > >> > I have a DB2 database on the IBM iSeries platform, on which I[/color][/color][/color]
                  created[color=blue][color=green][color=darkred]
                  > > >> > several Stored Procedures with the SQLCODE as a[/color][/color][/color]
                  return-parameter.[color=blue][color=green][color=darkred]
                  > > >> > These Stored Procedures are called from a Windows application[/color][/color][/color]
                  (build[color=blue]
                  > in[color=green][color=darkred]
                  > > >> > Visual Basic) using an ADO/OLE DB Provider on a IBM Client[/color][/color][/color]
                  Access[color=blue]
                  > ODBC[color=green][color=darkred]
                  > > >> > driver.
                  > > >> >
                  > > >> > On the Internet I found a whitepaper "SQL messages and codes"[/color][/color]
                  > provided[color=green][color=darkred]
                  > > >> > by IBM which describes a complete list of all SQLSTATEs,[/color][/color][/color]
                  SQLCODEs and[color=blue][color=green][color=darkred]
                  > > >> > their corresponding translation.
                  > > >> >
                  > > >> > They say all SQL-codes and messages are stored in the[/color][/color][/color]
                  QSQLMSG-file,[color=blue]
                  > and[color=green][color=darkred]
                  > > >> > to translate a SQLCODE (i.e. SQLCODE -204), I have to execute[/color][/color][/color]
                  the[color=blue][color=green][color=darkred]
                  > > >> > following command from the iSeries commandline:
                  > > >> >
                  > > >> >>> DSPMSGD RANGE(SQL0204) MSGF(QSQLMSG)
                  > > >> >
                  > > >> > Question is, how can I decipher my SQLcode from my windows[/color][/color]
                  > application?[color=green][color=darkred]
                  > > >> > i.e. with a SQL-command (????) like:
                  > > >> > select * from qsys2.qsqlmsg where code = 'SQL0204'
                  > > >> >
                  > > >> > Thanks for your help.
                  > > >> >
                  > > >> > Twan Kennis
                  > > >> > SKB Vragenlijst Services
                  > > >> > Amsterdam, The Netherlands
                  > > >> >
                  > > >> >
                  > > >> >
                  > > >> >
                  > > >>
                  > > >>
                  > > >
                  > > >[/color]
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Twan Kennis

                    #10
                    Re: How to decipher a SQLCODE - Finding the last piece

                    Hi,

                    Thank you all very much so far for your cooperation.

                    The reason I'd like to have the SQL-error description within my Windows
                    application (Visual Basic) is to diplay this description as part of my
                    error-message when for example a Stored Procedure failed.

                    Searching around on the public.boulder. ibm.com site I found a trace to
                    my solution, but the puzzle is not finsihed yet. Maybe anyone can help
                    me finding the last piece.

                    According to the IBM whitepaper "SQL messages and codes.pdf", (available
                    at:
                    http://publib.boulder.ibm.com/infoce...aprintthis.htm) a
                    SQLCODE can be translated with the CL-command "DSPMSGD" (Display Message
                    Description). Specs of this command are available at


                    Searching around how to execute a CL-command, I found the following
                    command: "QSYS.QCMDE XC" (information available at:
                    http://www.starquest.com/Supportdocs...0_qcmdexc.html)

                    Assembling all together, I *should* get the error description of i.e.
                    SQLCODE -204 by executing the following command from my SQL ODBC
                    interface:

                    CALL QSYS.QCMDEXC('D SPMSGD RANGE(SQL0204)
                    MSGF(QSQLMSG)', 0000000036.0000 0)

                    As a pity, all I get is "The command completed succesfully", and no
                    return paramater or SQL recordset containing the error description is
                    returned to me.

                    Thanks for your help again.

                    Twan Kennis,
                    SKB Vragenlijst Services
                    Amsterdam, The Netherlands



                    --
                    Groeten, Twan
                    SKB Vragenlijst Services, automatisering
                    "Karl Hanson" <kchanson@youes s.ibm.com> wrote in message
                    news:435f952a_3 @news1.prserv.n et...[color=blue]
                    > Rhino wrote:[color=green]
                    > > Hi Larry,
                    > >
                    > > I've never tried accessing an AS/400 from a Windows client. It[/color][/color]
                    occurred to[color=blue][color=green]
                    > > me that an SQLCode sent by an AS/400 might be one that is unique to[/color][/color]
                    AS/400[color=blue][color=green]
                    > > and I wasn't sure if a Windows client would know what to do with[/color][/color]
                    those.[color=blue][color=green]
                    > > Therefore, it seemed safer to query the AS/400 directly. But, now[/color][/color]
                    that I[color=blue][color=green]
                    > > reread the original post, I see that the code is SQL0204 which is[/color][/color]
                    present in[color=blue][color=green]
                    > > DB2 for Linux/Unix/Windows and OS/390. I *assume* it has the same[/color][/color]
                    meaning on[color=blue][color=green]
                    > > AS/400 as it does on those other platforms. So, it doesn't much[/color][/color]
                    matter which[color=blue][color=green]
                    > > platform's manuals (or command line tool) he uses since it should[/color][/color]
                    give[color=blue][color=green]
                    > > approximately the same answer.
                    > >
                    > > I still wonder what would happen if he specified a 'db2 ? sqlnnnn'[/color][/color]
                    if 'nnnn'[color=blue][color=green]
                    > > was unique to the platform where the data originated and did *not*[/color][/color]
                    occur on[color=blue][color=green]
                    > > the client. Oh well, one of these days I suppose I'll bump into that[/color][/color]
                    for[color=blue][color=green]
                    > > myself :-)
                    > >
                    > > Rhino
                    > >
                    > > "Larry Menard" <root@GoSpamYou rself.com> wrote in message
                    > > news:Q4KdneDwmP cgI8PeRVn-ug@rogers.com.. .
                    > >[color=darkred]
                    > >> Hey, Rhino.
                    > >>
                    > >> The server is iSeries, but the application is running on Windows.[/color][/color][/color]
                    The[color=blue][color=green][color=darkred]
                    > >>sqlcode being reported at the client app should be queried on the[/color][/color][/color]
                    client[color=blue][color=green][color=darkred]
                    > >>platform.
                    > >>--
                    > >>--------------------
                    > >>Larry Menard
                    > >>"Defender of Geese and of All Things Natural"
                    > >>[/color][/color]
                    >
                    > One misconception might be the assumption that the container of[/color]
                    iSeries[color=blue]
                    > messages corresponding to SQLCODEs is an SQL table:
                    >[color=green]
                    > > Question is, how can I decipher my SQLcode from my windows[/color][/color]
                    application?[color=blue][color=green]
                    > > i.e. with a SQL-command (????) like:
                    > > select * from qsys2.qsqlmsg where code = 'SQL0204'[/color]
                    >
                    > This is not possible (directly), because messages are stored in an
                    > OS/400 Message File (*MSGF) object, which is *not* an SQL table.
                    >
                    > If connected via an iSeries Access (aka Client Access) ODBC driver,
                    > there would normally be a QZDASOINIT job running on iSeries to process
                    > SQL requests from the client. It should be possible to locate this[/color]
                    job[color=blue]
                    > < eg OS/400 command: wrkactjob job(qzda*) > and see the SQL0204[/color]
                    message[color=blue]
                    > in the job log.
                    >
                    > --
                    > Karl Hanson[/color]


                    Comment

                    • Karl Hanson

                      #11
                      Re: How to decipher a SQLCODE - Finding the last piece

                      Twan Kennis wrote:[color=blue]
                      > Hi,
                      >
                      > Thank you all very much so far for your cooperation.
                      >
                      > The reason I'd like to have the SQL-error description within my Windows
                      > application (Visual Basic) is to diplay this description as part of my
                      > error-message when for example a Stored Procedure failed.
                      >
                      > Searching around on the public.boulder. ibm.com site I found a trace to
                      > my solution, but the puzzle is not finsihed yet. Maybe anyone can help
                      > me finding the last piece.
                      >
                      > According to the IBM whitepaper "SQL messages and codes.pdf", (available
                      > at:
                      > http://publib.boulder.ibm.com/infoce...aprintthis.htm) a
                      > SQLCODE can be translated with the CL-command "DSPMSGD" (Display Message
                      > Description). Specs of this command are available at
                      > http://publib.boulder.ibm.com/infoce...cl/dspmsgd.htm
                      >
                      > Searching around how to execute a CL-command, I found the following
                      > command: "QSYS.QCMDE XC" (information available at:
                      > http://www.starquest.com/Supportdocs...0_qcmdexc.html)
                      >
                      > Assembling all together, I *should* get the error description of i.e.
                      > SQLCODE -204 by executing the following command from my SQL ODBC
                      > interface:
                      >
                      > CALL QSYS.QCMDEXC('D SPMSGD RANGE(SQL0204)
                      > MSGF(QSQLMSG)', 0000000036.0000 0)
                      >
                      > As a pity, all I get is "The command completed succesfully", and no
                      > return paramater or SQL recordset containing the error description is
                      > returned to me.
                      >
                      > Thanks for your help again.
                      >
                      > Twan Kennis,
                      > SKB Vragenlijst Services
                      > Amsterdam, The Netherlands
                      >[/color]

                      When you call the QCMDEXC program from within an ODBC session, it is
                      running in what is considered an iSeries "batch" job (ie the
                      QZDASOINIT). This means there is no associated display session
                      associated with the job, so DSPMSGD produces a spooled file. If you try
                      this from an OS/400 command line:[color=blue]
                      > SBMJOB CMD(DSPMSGD RANGE(SQL0204) MSGF(QSQLMSG))
                      > WRKSBMJOB[/color]

                      ... and select option 8 for the submitted job (Work with spooled files),
                      you will see a file named QPMSGD. Using 5=Display you can see the
                      message text. One thought would be to create a stored procedure (CL
                      programs can be external stored procedures) that accepts the SQLCODE
                      (equivalent MSGID such as 'SQL0204') as an input parameter. The program
                      could run:
                      1) DSPMSGD using the input MSGID
                      2) CRTPF to create a physical file for CPYSPLF target
                      3) CPYSPLF to copy the QPMSGD spooled data to the physical file
                      After the message description is in the physical file it can be accessed
                      by SQL.

                      --
                      Karl Hanson

                      Comment

                      • Larry Menard

                        #12
                        Re: How to decipher a SQLCODE - Finding the last piece

                        I'm not familiar with VB, but I see examples of error message handling in
                        "sqllib\samples \vb\ado\cliExeS QL.bas" and "sqllib\samples \.net\vb\tbuse. vb".
                        The server platform from which the error comes should be irrelevant.

                        --
                        --------------------
                        Larry Menard
                        "Defender of Geese and of All Things Natural"


                        "Karl Hanson" <kchanson@youes s.ibm.com> wrote in message
                        news:4360d69b_2 @news1.prserv.n et...[color=blue]
                        > Twan Kennis wrote:[color=green]
                        >> Hi,
                        >>
                        >> Thank you all very much so far for your cooperation.
                        >>
                        >> The reason I'd like to have the SQL-error description within my Windows
                        >> application (Visual Basic) is to diplay this description as part of my
                        >> error-message when for example a Stored Procedure failed.
                        >>
                        >> Searching around on the public.boulder. ibm.com site I found a trace to
                        >> my solution, but the puzzle is not finsihed yet. Maybe anyone can help
                        >> me finding the last piece.
                        >>
                        >> According to the IBM whitepaper "SQL messages and codes.pdf", (available
                        >> at:
                        >> http://publib.boulder.ibm.com/infoce...aprintthis.htm) a
                        >> SQLCODE can be translated with the CL-command "DSPMSGD" (Display Message
                        >> Description). Specs of this command are available at
                        >> http://publib.boulder.ibm.com/infoce...cl/dspmsgd.htm
                        >>
                        >> Searching around how to execute a CL-command, I found the following
                        >> command: "QSYS.QCMDE XC" (information available at:
                        >> http://www.starquest.com/Supportdocs...0_qcmdexc.html)
                        >>
                        >> Assembling all together, I *should* get the error description of i.e.
                        >> SQLCODE -204 by executing the following command from my SQL ODBC
                        >> interface:
                        >>
                        >> CALL QSYS.QCMDEXC('D SPMSGD RANGE(SQL0204)
                        >> MSGF(QSQLMSG)', 0000000036.0000 0)
                        >>
                        >> As a pity, all I get is "The command completed succesfully", and no
                        >> return paramater or SQL recordset containing the error description is
                        >> returned to me.
                        >>
                        >> Thanks for your help again.
                        >>
                        >> Twan Kennis,
                        >> SKB Vragenlijst Services
                        >> Amsterdam, The Netherlands
                        >>[/color]
                        >
                        > When you call the QCMDEXC program from within an ODBC session, it is
                        > running in what is considered an iSeries "batch" job (ie the QZDASOINIT).
                        > This means there is no associated display session associated with the job,
                        > so DSPMSGD produces a spooled file. If you try this from an OS/400
                        > command line:[color=green]
                        > > SBMJOB CMD(DSPMSGD RANGE(SQL0204) MSGF(QSQLMSG))
                        > > WRKSBMJOB[/color]
                        >
                        > .. and select option 8 for the submitted job (Work with spooled files),
                        > you will see a file named QPMSGD. Using 5=Display you can see the message
                        > text. One thought would be to create a stored procedure (CL programs can
                        > be external stored procedures) that accepts the SQLCODE (equivalent MSGID
                        > such as 'SQL0204') as an input parameter. The program could run:
                        > 1) DSPMSGD using the input MSGID
                        > 2) CRTPF to create a physical file for CPYSPLF target
                        > 3) CPYSPLF to copy the QPMSGD spooled data to the physical file
                        > After the message description is in the physical file it can be accessed
                        > by SQL.
                        >
                        > --
                        > Karl Hanson[/color]


                        Comment

                        • Kent Milligan

                          #13
                          Re: How to decipher a SQLCODE

                          The Description method on the Connection object below should return the
                          message that you're looking for. Although you may need to have a handler
                          in the stored procedure.
                          Conn.Error(i).S QLSTATE & Conn.Error(i).D escription

                          Twan Kennis wrote:
                          [color=blue]
                          > Rhino,
                          >
                          > As a pity, there is no such "db2" commandlinetool available on my
                          > workstation. :-(
                          >
                          > Twan Kennis
                          >
                          >[/color]

                          --
                          Kent Milligan, DB2 & BI team
                          PartnerWorld for Developers, iSeries
                          kmill@us.eye-bee-m.com (spam trick) GO HAWKEYES!![color=blue][color=green][color=darkred]
                          >>> www.iseries.ibm.com/db2[/color][/color][/color]
                          (opinions stated are not necessarily those of my employer)

                          Comment

                          • Larry Menard

                            #14
                            Re: How to decipher a SQLCODE - Finding the last piece

                            But then again, if you don't have the "db2" executable (the full DB2
                            client), then you probably don't have the Samples. Look here:



                            --
                            --------------------
                            Larry Menard
                            "Defender of Geese and of All Things Natural"


                            "Larry Menard" <root@GoSpamYou rself.com> wrote in message
                            news:IfudnYFHso n3fv3eRVn-rA@rogers.com.. .[color=blue]
                            > I'm not familiar with VB, but I see examples of error message handling
                            > in "sqllib\samples \vb\ado\cliExeS QL.bas" and
                            > "sqllib\samples \.net\vb\tbuse. vb". The server platform from which the
                            > error comes should be irrelevant.
                            >
                            > --
                            > --------------------
                            > Larry Menard
                            > "Defender of Geese and of All Things Natural"
                            >
                            >
                            > "Karl Hanson" <kchanson@youes s.ibm.com> wrote in message
                            > news:4360d69b_2 @news1.prserv.n et...[color=green]
                            >> Twan Kennis wrote:[color=darkred]
                            >>> Hi,
                            >>>
                            >>> Thank you all very much so far for your cooperation.
                            >>>
                            >>> The reason I'd like to have the SQL-error description within my Windows
                            >>> application (Visual Basic) is to diplay this description as part of my
                            >>> error-message when for example a Stored Procedure failed.
                            >>>
                            >>> Searching around on the public.boulder. ibm.com site I found a trace to
                            >>> my solution, but the puzzle is not finsihed yet. Maybe anyone can help
                            >>> me finding the last piece.
                            >>>
                            >>> According to the IBM whitepaper "SQL messages and codes.pdf", (available
                            >>> at:
                            >>> http://publib.boulder.ibm.com/infoce...aprintthis.htm) a
                            >>> SQLCODE can be translated with the CL-command "DSPMSGD" (Display Message
                            >>> Description). Specs of this command are available at
                            >>> http://publib.boulder.ibm.com/infoce...cl/dspmsgd.htm
                            >>>
                            >>> Searching around how to execute a CL-command, I found the following
                            >>> command: "QSYS.QCMDE XC" (information available at:
                            >>> http://www.starquest.com/Supportdocs...0_qcmdexc.html)
                            >>>
                            >>> Assembling all together, I *should* get the error description of i.e.
                            >>> SQLCODE -204 by executing the following command from my SQL ODBC
                            >>> interface:
                            >>>
                            >>> CALL QSYS.QCMDEXC('D SPMSGD RANGE(SQL0204)
                            >>> MSGF(QSQLMSG)', 0000000036.0000 0)
                            >>>
                            >>> As a pity, all I get is "The command completed succesfully", and no
                            >>> return paramater or SQL recordset containing the error description is
                            >>> returned to me.
                            >>>
                            >>> Thanks for your help again.
                            >>>
                            >>> Twan Kennis,
                            >>> SKB Vragenlijst Services
                            >>> Amsterdam, The Netherlands
                            >>>[/color]
                            >>
                            >> When you call the QCMDEXC program from within an ODBC session, it is
                            >> running in what is considered an iSeries "batch" job (ie the QZDASOINIT).
                            >> This means there is no associated display session associated with the
                            >> job, so DSPMSGD produces a spooled file. If you try this from an OS/400
                            >> command line:[color=darkred]
                            >> > SBMJOB CMD(DSPMSGD RANGE(SQL0204) MSGF(QSQLMSG))
                            >> > WRKSBMJOB[/color]
                            >>
                            >> .. and select option 8 for the submitted job (Work with spooled files),
                            >> you will see a file named QPMSGD. Using 5=Display you can see the
                            >> message text. One thought would be to create a stored procedure (CL
                            >> programs can be external stored procedures) that accepts the SQLCODE
                            >> (equivalent MSGID such as 'SQL0204') as an input parameter. The program
                            >> could run:
                            >> 1) DSPMSGD using the input MSGID
                            >> 2) CRTPF to create a physical file for CPYSPLF target
                            >> 3) CPYSPLF to copy the QPMSGD spooled data to the physical file
                            >> After the message description is in the physical file it can be accessed
                            >> by SQL.
                            >>
                            >> --
                            >> Karl Hanson[/color]
                            >
                            >[/color]


                            Comment

                            • Twan Kennis

                              #15
                              Re: How to decipher a SQLCODE - Finding the last piece

                              Larry,

                              Thanx for for your help
                              I have the complete IBM iSeries Access for Windows Client installed, but
                              there is no "db2.exe" on my disc.

                              Main difference between the VB-examples you mentioned and my
                              application, is that I implemented (transactional) exception handling in
                              my Stored Procedures, which handles the error "within" my Stored
                              Procedure and does apply a rollback (or a commit when no error
                              occurred). Outside my Stored Procedure, there is nothing to remind me of
                              an error, beside my own result-parameter, which contains the SQLCODE if
                              an error occurred.

                              In the VB-examples you mentioned, there is no exception handling on DB2
                              applied. So when an error occurred by executing plain SQL or calling a
                              Stored Procedure, the error code and description come back with the
                              connection-object and can be read within the VB application.

                              Twan Kennis




                              "Larry Menard" <root@GoSpamYou rself.com> wrote in message
                              news:892dnd5g09 66av3eRVn-rw@rogers.com.. .[color=blue]
                              > But then again, if you don't have the "db2" executable (the full[/color]
                              DB2[color=blue]
                              > client), then you probably don't have the Samples. Look here:
                              >
                              >[/color]
                              http://publib.boulder.ibm.com/infoce...d/c0007609.htm[color=blue]
                              >
                              > --
                              > --------------------
                              > Larry Menard
                              > "Defender of Geese and of All Things Natural"
                              >
                              >
                              > "Larry Menard" <root@GoSpamYou rself.com> wrote in message
                              > news:IfudnYFHso n3fv3eRVn-rA@rogers.com.. .[color=green]
                              > > I'm not familiar with VB, but I see examples of error message[/color][/color]
                              handling[color=blue][color=green]
                              > > in "sqllib\samples \vb\ado\cliExeS QL.bas" and
                              > > "sqllib\samples \.net\vb\tbuse. vb". The server platform from which[/color][/color]
                              the[color=blue][color=green]
                              > > error comes should be irrelevant.
                              > >
                              > > --
                              > > --------------------
                              > > Larry Menard
                              > > "Defender of Geese and of All Things Natural"
                              > >
                              > >
                              > > "Karl Hanson" <kchanson@youes s.ibm.com> wrote in message
                              > > news:4360d69b_2 @news1.prserv.n et...[color=darkred]
                              > >> Twan Kennis wrote:
                              > >>> Hi,
                              > >>>
                              > >>> Thank you all very much so far for your cooperation.
                              > >>>
                              > >>> The reason I'd like to have the SQL-error description within my[/color][/color][/color]
                              Windows[color=blue][color=green][color=darkred]
                              > >>> application (Visual Basic) is to diplay this description as part[/color][/color][/color]
                              of my[color=blue][color=green][color=darkred]
                              > >>> error-message when for example a Stored Procedure failed.
                              > >>>
                              > >>> Searching around on the public.boulder. ibm.com site I found a[/color][/color][/color]
                              trace to[color=blue][color=green][color=darkred]
                              > >>> my solution, but the puzzle is not finsihed yet. Maybe anyone can[/color][/color][/color]
                              help[color=blue][color=green][color=darkred]
                              > >>> me finding the last piece.
                              > >>>
                              > >>> According to the IBM whitepaper "SQL messages and codes.pdf",[/color][/color][/color]
                              (available[color=blue][color=green][color=darkred]
                              > >>> at:
                              > >>>[/color][/color][/color]
                              http://publib.boulder.ibm.com/infoce...aprintthis.htm) a[color=blue][color=green][color=darkred]
                              > >>> SQLCODE can be translated with the CL-command "DSPMSGD" (Display[/color][/color][/color]
                              Message[color=blue][color=green][color=darkred]
                              > >>> Description). Specs of this command are available at
                              > >>>[/color][/color][/color]
                              http://publib.boulder.ibm.com/infoce...cl/dspmsgd.htm[color=blue][color=green][color=darkred]
                              > >>>
                              > >>> Searching around how to execute a CL-command, I found the[/color][/color][/color]
                              following[color=blue][color=green][color=darkred]
                              > >>> command: "QSYS.QCMDE XC" (information available at:
                              > >>> http://www.starquest.com/Supportdocs...0_qcmdexc.html)
                              > >>>
                              > >>> Assembling all together, I *should* get the error description of[/color][/color][/color]
                              i.e.[color=blue][color=green][color=darkred]
                              > >>> SQLCODE -204 by executing the following command from my SQL ODBC
                              > >>> interface:
                              > >>>
                              > >>> CALL QSYS.QCMDEXC('D SPMSGD RANGE(SQL0204)
                              > >>> MSGF(QSQLMSG)', 0000000036.0000 0)
                              > >>>
                              > >>> As a pity, all I get is "The command completed succesfully", and[/color][/color][/color]
                              no[color=blue][color=green][color=darkred]
                              > >>> return paramater or SQL recordset containing the error description[/color][/color][/color]
                              is[color=blue][color=green][color=darkred]
                              > >>> returned to me.
                              > >>>
                              > >>> Thanks for your help again.
                              > >>>
                              > >>> Twan Kennis,
                              > >>> SKB Vragenlijst Services
                              > >>> Amsterdam, The Netherlands
                              > >>>
                              > >>
                              > >> When you call the QCMDEXC program from within an ODBC session, it[/color][/color][/color]
                              is[color=blue][color=green][color=darkred]
                              > >> running in what is considered an iSeries "batch" job (ie the[/color][/color][/color]
                              QZDASOINIT).[color=blue][color=green][color=darkred]
                              > >> This means there is no associated display session associated with[/color][/color][/color]
                              the[color=blue][color=green][color=darkred]
                              > >> job, so DSPMSGD produces a spooled file. If you try this from an[/color][/color][/color]
                              OS/400[color=blue][color=green][color=darkred]
                              > >> command line:
                              > >> > SBMJOB CMD(DSPMSGD RANGE(SQL0204) MSGF(QSQLMSG))
                              > >> > WRKSBMJOB
                              > >>
                              > >> .. and select option 8 for the submitted job (Work with spooled[/color][/color][/color]
                              files),[color=blue][color=green][color=darkred]
                              > >> you will see a file named QPMSGD. Using 5=Display you can see the
                              > >> message text. One thought would be to create a stored procedure[/color][/color][/color]
                              (CL[color=blue][color=green][color=darkred]
                              > >> programs can be external stored procedures) that accepts the[/color][/color][/color]
                              SQLCODE[color=blue][color=green][color=darkred]
                              > >> (equivalent MSGID such as 'SQL0204') as an input parameter. The[/color][/color][/color]
                              program[color=blue][color=green][color=darkred]
                              > >> could run:
                              > >> 1) DSPMSGD using the input MSGID
                              > >> 2) CRTPF to create a physical file for CPYSPLF target
                              > >> 3) CPYSPLF to copy the QPMSGD spooled data to the physical file
                              > >> After the message description is in the physical file it can be[/color][/color][/color]
                              accessed[color=blue][color=green][color=darkred]
                              > >> by SQL.
                              > >>
                              > >> --
                              > >> Karl Hanson[/color]
                              > >
                              > >[/color]
                              >
                              >[/color]


                              Comment

                              Working...