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



Mike,

You need to investigate the DESCRIBE function.  It will return into
the SQLDA the format of the fields in your dynamically prepared SQL
Statement.  I found it a little cumbersome but it can be done.  

I'm under time contraints right now and I don't have time to figure
out exactly how I did it.  But I hope this helps.

Regards,
Russell Conerly
Tupelo, MS


Here's an example

D  sql_num        c                   const(100)   

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                                   
                                               
-------------------
> We have an app that uses a dynamically generated SQL statement to
query out
> a set of records.  Files, fields, sorts, etc. are stored in a file,
so we
> have no way of knowing what the recordset will look like at compile
time.
> Because of this, we're having problems using Fetch in any sort of
> meaningful way.  We know how to Fetch into a DS or a bunch of
variables,
> but both seem to require knowing what the recordset looks like at
compile
> time.  If we have more variables in the Fetch Cursor Into statement
than we
> have in the recordset, will this be a problem?
> 
> All we want to do is dump the recordset into a work file so we can
export
> that out to a PC file.  Unfortunately we're still on V5R1, so we
don't have
> Create Table As.
> 
> Mike E.
> 
> 
> 
> _______________________________________________
> 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.