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


  • Subject: RE: SQL Statements embedded in RPG
  • From: "Russell Conerly" <rconerly@xxxxxxxxxxx>
  • Date: Thu, 17 Feb 2000 10:03:08 -0600
  • Importance: Normal

You might try something like this.  If I'm following your example.

Russell Conerly
SCB Computer Technology


D forever         s               n   inz(*on)
D ORDERNUM                       7P 0
D tot_open_qty                   9P 0

 **********************************************************************
 ** DECLARE SQL CURSORS                                              **
 **********************************************************************
C/exec sql declare ORDERHEADER cursor for
C+ select ordernum from ordhdr where ordrstat = 'OPEN'
C+ for read only
C/end-exec

C/exec sql declare ORDERDETAIL cursor for
C+ select sum(ordqty) from ordhdr where dtlorder = ordernum
C+ for read only
C/end-exec

 **********************************************************************
 **********************************************************************
C/exec sql
C+ open ORDERHEADER
C/end-exec

c                   dow       forever
C/exec sql
C+ FETCH NEXT FROM ORDERHEADER INTO :ORDERNUM
C/end-exec
C                   if        sqlcod = 100
C                   leave
C                   endif
C/exec sql
C+ OPEN ORDERDETAIL
C/end-exec
c                   dow       forever
C/exec sql
C+ FETCH NEXT FROM ORDERDETAIL INTO :tot_open_qty
C/end-exec
C                   if        sqlcod = 100
C                   leave
C                   endif
C                   enddo

C/exec sql
C+ CLOSE ORDERDETAIL
C/end-exec

C                   enddo

C/exec sql
C+ CLOSE ORDERHEADER
C/end-exec


-----Original Message-----
From: owner-rpg400-l@midrange.com [mailto:owner-rpg400-l@midrange.com]On
Behalf Of JFinney@omnia.co.za
Sent: Thursday, February 17, 2000 7:21 AM
To: RPG400-L@midrange.com
Subject: SQL Statements embedded in RPG


Hi All,

I've recently started to "get my hands dirty" with SQL on the '400 and am
battling to get my head around some issues.
Say, for instance, in traditional RPG logic + LF's, one would chain/reade
(loop) a logical and, for each record, go to
another loop and chain/reade based on a key (keeping it simple to start,
assume the unique key to be one field from the
original LF).

 What would the SQL statement look like to do the equivalent of what's just
been explained in the previous paragraph ?

Hope this question is clear enough (seems a little murky upon a re-read).
If anyone is unclear, please e-mail me and I'll
try to ask with a little more clarity.

Regards
John.


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator:
david@midrange.com
+---

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@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.