× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Here is a CL program that places the interpretation in the job message queue for debugging purposes. I also this from the RPG.

SQLCODE: PGM PARM(&CODE &PSMSG)
DCL VAR(&CODE) TYPE(*INT) /* Error Code from SQLCOD */
DCL VAR(&PSMSG) TYPE(*CHAR) LEN(70) /* Message Data from SQLCOD */
DCL VAR(&MSG) TYPE(*CHAR) LEN(70) /* Interpreted Message */

DCL VAR(&TEST) TYPE(*DEC) LEN(4 0)
DCL VAR(&SCODE) TYPE(*CHAR) LEN(4)
DCL VAR(&SQLCODE) TYPE(*CHAR) LEN(7)
/* check parameters */
CHGVAR VAR(&MSG) VALUE(&PSMSG)
MONMSG MSGID(CPF0000) EXEC(DO)
CHGVAR VAR(&MSG) VALUE(' ')
ENDDO
/* Translate error code to get the last four characters of the Message code */
CHGVAR VAR(&TEST) VALUE(&CODE * -1)
IF COND(&TEST > &CODE) THEN(CHGVAR VAR(&CODE) +
VALUE(&TEST))
CHGVAR VAR(&SCODE) VALUE(&CODE)
IF COND(&CODE > 999) THEN(DO)
CHGVAR VAR(&SQLCODE) VALUE('SQ1' || &SCODE)
ENDDO
ELSE CMD(DO)
CHGVAR VAR(&SQLCODE) VALUE('SQL' || &SCODE)
ENDDO

SNDPGMMSG MSG('**** SQL Message Decode Follows ****')
SNDPGMMSG MSGID(&SQLCODE) MSGF(QSQLMSG) MSGDTA(&MSG)
SNDPGMMSG MSG('**** SQL Message Decode Complete ****')

ENDPGM

Thanks,

Marvin
------------------------------

message: 5
date: Wed, 22 Oct 2008 14:25:13 -0500
from: "Lim Hock-Chai" <Lim.Hock-Chai@xxxxxxxxxxxxxxx>
subject: Using SQLCODE to access QSQLMSG

I was under the impression that I can retrieve the SQL error message by
concatenating the text "SQL" and SQLCode to form the message ID. See
link
below:http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?to
pic=/rzala/rzalamess.htm . Is this correct? If so, how should I deal
with SQL code that is greater the 9999?


------------------------------


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.