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



what is the SQLCOD & SQLSTT after the fetch??? or even after the open??

If the cursor didn't open is one way it could happen...too many possibilities & 
not enough info to really help...

Thanks,
Tommy Holden


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Brian Piotrowski
Sent: Wednesday, July 13, 2005 12:49 PM
To: RPG programming on the AS400 / iSeries
Subject: Moving Values from SQL -> RPG


Hi All,

 

I'm having a small problem moving values in from my SQL to my RPG.  I
have a FETCH command that obtain five values from an SQL statement.
When I declare the SQL statement, it works fine (it has the appropriate
values in the variable names).  However, once it goes to fetch the
values into the variables I have set up, it always comes up with blanks.

 

Can someone tell me if I am doing something wrong? 

 

Thanks!


Brian.

 

Here's the code I am using:

 

C/Exec SQL

c+ declare MyCursor cursor for

C+ SELECT soptno, soptcl, SOKDL2, SOKDL3,

C+ ((:inhse+:iyard)-(select sum(soqty) from SSWDPSO

C+ where SOKDL3<=a.SOKDL3

C+ and soptno=:partno and soptcl=:partcl))

C+ FROM SSWDPSO a where soptno=:partno

C+ and soptcl=:partcl group by soptno, soptcl,

C+ SOKDL2, SOKDL3 having

C+ (select sum(soqty) from SSWDPSO

C+ where SOKDL3<=a.SOKDL3 and soptno=:partno

C+ and soptcl=:partcl) > (:inhse+:iyard)

C/End-Exec

 

C/exec SQL

c+ open MyCursor

c/end-exec

 

c/exec sql

c+ fetch MyCursor into :curptno, :curptcl, :curkym, :curkrrn, :cursqty

c/end-exec

C*

C/Exec SQL

C+ Close MyCursor

C/End-exec

C*

C*

C* Add the updated values to the DMDPG_PF file

  /free

     SQLstmt = 'Update DMDPG_PF set shortqty = ' + %char(cursqty);

     SQLstmt = SQLstmt + ' ,skdlym=' + apos + curkym + apos;

     SQLstmt = SQLstmt + ' ,skdlrrn=' + apos + curkrrn + apos;

     SQLstmt = SQLstmt + ' WHERE plcd = ' + apos + plcd + apos;

     SQLstmt = SQLstmt + ' AND partno = ' + apos + curptno + apos;

     SQLstmt = SQLstmt + ' AND partcl = ' + apos + curptcl + apos;

  /end-free

C*

 

-=-=-=-=-=-=-=-=-=-=-=-=-=-

Brian Piotrowski

Specialist - I.T.

Simcoe Parts Service, Inc.

Ph: 705-435-7814 x343

Fx: 705-435-6746

bpiotrowski@xxxxxxxxxxxxxxx

-=-=-=-=-=-=-=-=-=-=-=-=-=-

 


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.