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



Thanks!

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Mark Murphy
Sent: Thursday, October 31, 2019 3:28 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: SQL Codes

Here's how I do it, similar to Dave:

OpenCursor();
dow FetchCursor(rec);
... Process rec
enddo;
CloseCursor();

Some notes on that; there are three procedures. OpenCursor() holds the SQL
to declare and open the cursor. The declaration is there because if you
pass in variables as parameters, the declaration needs to be in scope.
Otherwise the declaration does not need to be there, and can be at the head
of the program. I like to keep it close to it's usage point.
FetchCursor(rec) returns the record read from the cursor in a parameter,
and an indicator that is *On when a record is successfully read.
CloseCursor() does exactly what it sounds like. The nice thing about this
setup is that the main logic is not cluttered by SQL, and you don't need to
worry about maintaining SQL Codes. If you are inside the loop, then you got
a record.

On Thu, Oct 24, 2019 at 11:59 AM Greg Wilburn <
gwilburn@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

Thanks all..

Do you have simple example?

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of
dlclark@xxxxxxxxxxxxxxxx
Sent: Thursday, October 24, 2019 11:55 AM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: SQL Codes

Because of that I don't condition my loops on the SQL code or
state. I use a separate named indicator, instead.


Sincerely,

Dave Clark
--
int.ext: 91078
direct: (937) 531-6378
home: (937) 751-3300

Winsupply Group Services
3110 Kettering Boulevard
Dayton, Ohio 45439 USA
(937) 294-5331



"RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> wrote on 10/24/2019
11:45:27 AM:
You are correct, there is one global SQLCA DS.

So you have to save the results of previous SQL statements to avoid a
scenario as written.

Kind regards,

Carel Teijgeler


Op 24-10-2019 om 17:29 schreef Greg Wilburn:
I have an RPG program that is using an SQL Cursor to read through
data... it then calls two internal procedures that also use SQL
select statements.

Would I be correct in stating that the SQLCA is not "exclusive"
inside each of the procedures?

What appears to be happening is that Select statement inside on of
the procedures is setting the SQL State to '0200' causing my DOU
loop to end in the main body of the program.



*********************************************************************************************
This email message and any attachments is for use only by the named
addressee(s) and may contain confidential, privileged and/or proprietary
information. If you have received this message in error, please
immediately notify the sender and delete and destroy the message and all
copies. All unauthorized direct or indirect use or disclosure of this
message is strictly prohibited. No right to confidentiality or privilege
is waived or lost by any error in transmission.

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

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.