• Subject: Re: Embedded SQL
  • From: rob@xxxxxxxxx
  • Date: Wed, 25 Apr 2001 13:15:30 -0500


Host variables begin with a : or colon.  I made 3 changes.
1)  Added variable DateSel
2)  Added 'into :Total'
3)  Changed 1000701 to :DateSel


     D DateSel         S              7S 0 Inz(1000701)
     D Total           S             15S 2 Inz(0)
      *--------------------------------------------------------------------
     C/Exec Sql
     C+   select Sum(T2ANVA) into :Total                    Amount
     C+ From NEWHUD/TNTRTH
     C+ Where T2HSDT >= :DateSel and T2BICD = '01'          Date & Trans
Type
     C/End-Exec


Hope this helps!

Rob Berendt

==================
Remember the Cole!


                                                                                
                                         
                    Cyndi Bradberry                                             
                                         
                    <CyndiB@IHFA.ORG>          To:     "'Midrange-L@midrange. 
com' (E-mail)" <Midrange-L@midrange.com>   
                    Sent by:                   cc:                              
                                         
                    owner-midrange-l@mi        Subject:     Embedded SQL        
                                         
                    drange.com                                                  
                                         
                                                                                
                                         
                                                                                
                                         
                    04/25/01 12:32 PM                                           
                                         
                    Please respond to                                           
                                         
                    MIDRANGE-L                                                  
                                         
                                                                                
                                         
                                                                                
                                         




I am an SQL newbie, we have only had SQL for 9 days now.  I am trying to
read the manuals, but they are not answering a question.

We have been asked to total up transaction records, (different trans types,
4 different amounts on each record). They want the total of each column, by
each trans type and then the foot of all the columns, with all the totals
printed on a report.

I have figured out how to do this with the STRSQL command, (one column and
one trans type at a time) but not how to do it with SQLRPGLE.  Here is my
program, but the SQL precompiler said that I needed a SELECT INTO
statement.
How do I get the Sum(field name) into a field for doing further
calculations
(Total) ?

     FQPRINT    O    F   80        Printer OFLIND(*INOF)

     D Total           S             15S 2 Inz(0)
      *--------------------------------------------------------------------
     C/Exec Sql
     C+   select Sum(T2ANVA)                               Amount
     C+ From NEWHUD/TNTRTH
     C+ Where T2HSDT >= 1000701 and T2BICD = '01'          Date & Trans
Type
     C/End-Exec
     C                   Except    #detail
     C                   Eval      *INLR = *On
     OQprint    E            #Detail
     O                       Total         4     35

Do I make any sense ?  I don't want to do this with plain RPGIV or WRKQRY,
I
really want to use this new functionality.  Can someone please give me a
clue ? I have three SQL manuals from IBM, and the SQL tutorial from
News/400.

TIA,
Cyndi B.
Boise, ID
+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to
MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator:
david@midrange.com
+---



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

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 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].