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



Brian,

If you are going to get more than one record with SQL, you *have to* use
a cursor. You should check the value of SQLSTT to control your loop (you
can use SQLCOD but SQLSTT is the recommended practice). If a FETCH was
successful, SQLSTT will start with 00 or 01 (SQLSTT's that start with 01
are informational messages that can generally be ignored). Your program
will be something like this (note that this is more pseudo code than
real code):

- DECLARE CURSOR
- OPEN CURSOR
- While SQLSTT starts with 00 or 01
  - FETCH FROM CURSOR
  - do stuff
- CLOSE CURSOR

Also, if you go the CSV route, you should be aware that Excel does not
handle CSV files correctly. Specifically, if you have a numeric looking
field that starts with zeros, Excel will drop the leading zeros even if
you enclose the value in double quotes (this causes lots of problems
with things like ISBNs). There is an escape character you can add to
prevent this from happening in Excel but I don't recall what it is.

Matt

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Brian Piotrowski
Sent: Thursday, September 15, 2005 9:26 AM
To: RPG programming on the AS400 / iSeries
Subject: RE: Filling a Subfile with an SQL statement / Writing a CSV

Thanks.  My only question is how do you move forward in the recordset?
I'm assuming if you are writing the results, you would need to be able
to go through the results one by one, correct?

Brian.

-----Original Message-----
From: Geeky400 [mailto:Geeky400@xxxxxxxxxxx] 
Sent: Thursday, September 15, 2005 8:34 AM
To: RPG programming on the AS400 / iSeries
Subject: Re: Filling a Subfile with an SQL statement / Writing a CSV

Hi Brian,

...and for the first question you can test SQLCOD, ie, DoW SQLCOD = 0

Hope this helps,

G4!


Peter.Colpaert@xxxxxxxxxx wrote:

>Brian,
>
>regarding your second question,  you could always use the Jakarta POI 
>classes to output a "real" excel sheet, and have the user pick it up
from 
>the IFS, or mail it to him/her.
>
>Alternatively, you could output to a workfile, and have the user import
it 
>into excel using the iSeries Access data transfer add-in.
>
>HTH,
>
>Peter Colpaert
>Application Developer
>Massive - Kontich, Belgium
>-----
>Yoda of Borg are we.  Futile is resistance, assimilated will you be.
>-----
>
>
>
>
>"Brian Piotrowski" <bpiotrowski@xxxxxxxxxxxxxxx>
>Sent by: rpg400-l-bounces@xxxxxxxxxxxx
>15/09/2005 14:10
>Please respond to RPG programming on the AS400 / iSeries
>
> 
>        To:     "RPG programming on the AS400 / iSeries"
<rpg400-l@xxxxxxxxxxxx>
>        cc: 
>        Subject:        Filling a Subfile with an SQL statement /
Writing a CSV
>
>
>Hi All,
>
> 
>
>When I use an SQL statement to obtain information to a database, do I
>need to create a cursor in order to write the data to a subfile?  Is
>there a way to do something like a DoW not %eof(SQL returned records)?
>
> 
>
>The other question I have regards writing a CSV file.  Right now, we
>have a null device where all of our "scratch" data is written (PRT01).
>One of the users on our system needs to have the results of a query
>written to a file that will be exported to an Excel spreadsheet.  I was
>planning on simply writing the file to our scratch drive and have them
>grab the print file using Navigator.  Does anyone know if there is a
>better way to do this?
>
> 
>
>Thanks!
>
>
>
>Brian.
>
> 
>
>-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
>Brian Piotrowski
>
>Specialist - I.T.
>
>Simcoe Parts Service, Inc.
>
>Ph: 705-435-7814 x343
>
>Fx: 705-435-6746
>
>bpiotrowski@xxxxxxxxxxxxxxx
>
>-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> 
>
>  
>



                
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new
Yahoo! Security Centre. http://uk.security.yahoo.com

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.