Hi Tim
try interactive sql (STRSQL) and type
select * from filename
then press F4 for prompt
Prompt (F4) On the line
SELECT fields  . . . . . . .
how is this 7-element array defined?
Alan Shore
Programmer/Analyst, Direct Response
E:AShore@xxxxxxxx
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill
                                                                       
             "Timothy Adair"                                           
             <tadair@prairiefa                                         
             rms.com>                                                   To
             Sent by:                  rpg400-l@xxxxxxxxxxxx           
             rpg400-l-bounces@                                          cc
             midrange.com                                              
                                                                   Subject
                                       Dynamic SQL fetch into an array 
             06/11/2010 04:34                                          
             PM                                                        
                                                                       
                                                                       
             Please respond to                                         
              RPG programming                                          
              on the IBM i /                                           
                 System i                                              
             <rpg400-l@midrang                                         
                  e.com>                                               
                                                                       
                                                                       
After beating my head against this issue, I've searched the archives and
the
Internet with no luck.  I am attempting to fetch a record in embedded SQL
and this record includes a 7-element array.  I'm fetching from a
program-described file (QS36F).
I've oversimplified the code below - I just need to get the basic concept.
    d SchRecord       ds
    d   c@                    1      5  0
    d   typi                  6      6  0
    d   fschi                 7      7  0
    d   cyci                  8      8  0
    d   arrRT                        3  0 dim(7)
      sqlstmt = 'select                     +
               substr(K00001,1,5) as c@,    +
               substr(K00001,6,1) as typi,  +
               substr(K00001,7,1) as fschi, +
               substr(K00001,8,1) as cyci,  +
               substr(F00001,1,21) as arrRT +
               from qs36f/"DS.SCH"
  exec sql
      prepare P1 from :sqlstmt;
  exec sql
      declare C1 cursor for P1;
  exec sql
      open C1;
      dou sqlstt <> '00000';
  exec sql
      fetch C1 into :SchRecord;
          if sqlstt <> '00000';
              leave;
          endif;
Etc.
The other fields read in properly but "arrRT" reads in as a single 3-digit
field instead of an array of seven 3-digit elements.  I defined it as an
array in the DS - why does SQL ignore that?
I have to do this as dynamic because of the "where" and "order by" clauses
that are needed.
Any thoughts are appreciated.  I'm starting to feel like Danny Noonan in
Caddyshack ("right in the lumber yard").
TA
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: 
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at 
http://archive.midrange.com/rpg400-l.
 
As an Amazon Associate we earn from qualifying purchases.