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



True...

I *generally* used DoU SQLCOD=100

But DoU SQLSTT='02000' seems more appropriate these days...

Of course when I first started with embedding SQL I learned using SQLCOD
(I wasn't even aware SQLSTT was an option...happens when you don't
RTM...)

Learning from others is a good thing...but I highly recommend using
other resources as well.  Sometimes there may be better ways than just
what the other person showed you.... 


Thanks,
Tommy Holden


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of HauserSSS
Sent: Thursday, September 15, 2005 1:57 PM
To: RPG programming on the AS400 / iSeries
Subject: AW: Filling a Subfile with an SQL statement / Writing a CSV

Hi guys,


>>The line with SQLCOD should read: "Dow    SQLCOD = 0"

I've now read in several answers to use SQLCOD = *Zeros.
You should avoid this and either use SQLCOD = 100 to check if not found
or even better to use SQLSTT '2000'.
To detect an error you have to check for a negative SQLCOD.

Beginning with release V5R1M0 there are several situations where a row
is returned, but an SQLCOD between 1 and 99, a warning, is sent.

For example you'll get SQLCOD 30, if you join two files and only read
the information of the first one into an external data structure.

D DSFile1     E  DS                  ExtName('FILE1')

C/EXEC SQL
C+ Declare CsrC1 Cursor for
C+    Select *
C+       from File1 join File 2 on File1.Key = File2.Key
C+       Where File1.Fld = 'XXX' and File2.Fld = 'ABC'
C/END-EXEC

C/EXEC SQL   Open CsrC1
C/END-EXEC

C/EXEC SQL   Fetch Next From CsrC1 Into :DSFile1
C/END-EXEC

--> SQLCOD is now 30, but the row is returned!!!

By the way, to learn embedded SQL there are several redbooks where also
a lot of examples can be found:
Who Knew You Could Do That with RPG IV? A Sorcerer's Guide to System
Access and More http://www.redbooks.ibm.com/abstracts/sg245402.html?Open

Modernizing IBM eServer iSeries Application Data Access - A Roadmap
Cornerstone http://www.redbooks.ibm.com/abstracts/sg246393.html?Open

Birgitta

--
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-Ups:

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.