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



This may get you started.  I took the liberty to cut out the build of
the statement. Sql_num is set at 100.  The assumption was that no file
used by this program would contain more than 100 fields.

D  sql_num        c                   const(100)                   
D  poskey         s             80
D  i              S              5  0                                 
DFldDS1           DS                                               
D FldArr1                      128A   Dim(SQL_NUM) Inz(*Blanks)    
D IndArr1                         N   Dim(SQL_NUM) Inz(*Off)       
                                                                   
                                                                   
 ******************************************************************
 **  Prepare & Declare SQL Cursor                                  
 ******************************************************************
                                                                   
C                   eval      sqln = sql_num                       
C                   eval      sqldabc = (sqln * %len(SQLVAR)) + 16 
                                                                   
C/EXEC SQL                                                         
C+ INCLUDE SQLDA   
C/END-EXEC                                                        
                                                                  
C/EXEC SQL                                                        
C+ PREPARE SQLSTMNT FROM :statement                               
C/END-EXEC                                                        
                                                                  
C/EXEC SQL                                                        
C+ DESCRIBE SQLSTMNT INTO :SQLDA USING ALL                        
C/END-EXEC                                                        
                                                                  
C/EXEC SQL                                                        
C+ DECLARE A1 CURSOR FOR SQLSTMNT                                 
C/END-EXEC                                                        
                                                                  
C                   do        1             i                 
C                   eval      SQLVAR     = SQL_VAR(I)                 
C                   eval      SQLDATA    = %addr(FldArr1(I))  
C                   eval      SQLIND     = %addr(IndArr1(I))      
C                   eval      SQL_VAR(I) = SQLVAR             
C                   EndDo                                     
                                                              
 *************************************************************
 **  Open Cursor and process file to build subfile            
 *************************************************************
                                                              
C/exec sql                                                    
C+ OPEN A1                                                    
C/end-exec                                                    
                                                              
C                   DOU       SQLCOD = 100                    
C                   if        sqlcod = 0                      
C                   if        sqltype = 452 or sqltype = 453  
C/exec sql                                                    
C+ FETCH NEXT FROM A1 INTO :choice1,:choice2
C/end-exec   

                                                      
C                   else  
 
*  If Numeric
                                                     
C                   if        sqltype = 484 or sqltype = 485 or    
C                             sqltype = 488 or sqltype = 489       
C/exec sql                                                         
C+ FETCH NEXT FROM A1 INTO :choice1N,:choice2                      
C/end-exec                                                         
C                   eval      choice1 = %editc(choice1n:'Z')       
C                   endif                                          
C                   endif                                          
C                   if        sqlcod = 0                           
C                   eval      rrn1   = rrn1 + 1                    
C                   eval      *in50  = *on                         
C                   eval      CHC1   = %TRIM(choice1)              
C                   eval      dspfld = CHC1 + ' ' + %trim(choice2) 
C                   write     sflrcd01
C                   endif                
C                   endif                
C                   enddo                
C/exec sql                               
C+ close a1                              
C/end-exec                               
            

Maybe this will give you some direction.

Regards,

Russell Conerly
IBM Certified Specialist - 
RPG IV Developer
Tupelo, MS                             

                                                                      
                               
-------------------
> Anybody has a good running sample of a SQL DESCRIBE using SQLDA ?
> Trying to figure out how to fetch, if the column list is unknown,
> I have searched the archives, but wasn;t able to find a good sample.
> Thanks for any help in advance.
> Ali
> 
> _______________________________________________
> This is the RPG programming on the AS400 / iSeries (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.

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.