× 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.



I solved some problems like this by stopping the program (in debug) on the
statement where your SQLCOD is being tested - take the SQLCOD (ie. -204) and
lookup up the message description in the message file QSQLMSG. The message
ID will be 'SQLxxxx' where 'xxxx' is the last 4 digits of the SQLCOD, 0204
in this example.

Sometimes, the message will shed some light on the problem.

hth

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Guy Henza
Sent: Monday, June 21, 2004 12:36 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: SQL Statements in ILE RPG 


I wrote a nice little embeded SQL in a RPGLE program.  I tested the 
statement in STRSQL and got 2965 rows returned.  When I run it in my RPGLE I

get 39 rows...

C/exec sql declare c1 cursor for
C+    select cnme, bsdst#, substring(bssdat,1,6), sum(bsexbs)
C+      from bsf100s
C+      join brcm    on bsdst# = rcusno
C+      join rcm     on bsdst# = ccust
C+     where substring(bssdat,1,6) between :strdat and :enddat
C+       and bsrtyp = 'S'
C+     group by cnme, bsdst#, substring(bssdat,1,6)
C+     order by cnme, bsdst#, substring(bssdat,1,6)
C/end-exec

C/exec sql
C+  open c1
C/end-exec

C     sqlcod        doune     0
C/exec sql
C+ FETCH NEXT FROM C1 INTO :icnme, :idst#, :isdat, :iexbs
C/end-exec

I changed doune 0 to doueq 100 and got most of my expected data.  BUT I'm 
still missing some.

The SQLCODE is also set by the database manager after each SQL statement is 
executed as follows:

If SQLCODE = 0 and SQLWARN0 is blank, execution was successful.
If SQLCODE = 100, no data was found. For example, a FETCH statement returned

no data, because the cursor was positioned after the last row of the result 
table.
If SQLCODE > 0 and not = 100, execution was successful with a warning.
If SQLCODE = 0 and SQLWARN0 = 'W', execution was successful with a warning.
If SQLCODE < 0, execution was not successful.
A complete listing of DB2 UDB for iSeries SQLCODEs and their corresponding 
SQLSTATEs is provided in the SQL Messages and Codes book in the iSeries 
Information Center.

I tried reading the "SQL Messages and Codes book" and I think Greek would be

easier to understand.

IF SQLCOD is not equal 0 ang not equal to 100 can I still use the data?

Guy Henza
guyhenza@xxxxxxxxxxx

_________________________________________________________________
MSN Toolbar provides one-click access to Hotmail from any Web page - FREE 
download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/

--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

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.