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



I think somebody already answered your original question.  This is not
related to your question but, I think, would be nice to do.

The problem about prepare sql statement on the fly is that it is very
hard figure out what the resulted sql statement looks like.  Below is
the method that I started to do to get around this problem:

c                   eval      sqlstmt =                                
c                              'insert into &fileName ' +              
c                              '  values(&FIELD1, &FIELD2, ' +         
c                              '         &FIELD3, &FIELD4, ' +         
c                              '         &FIELD5)'                     
                                                                       
 * replace tag value with actual values                                
c                   callp     replaceTag('fileName' :filNam :sqlStmt)

c                   callp     replaceTag('FIELD1' :value1 :sqlStmt :*on)
c                   callp     replaceTag('FIELD2' :value1 :sqlStmt)    
c                   callp     replaceTag('FIELD3' :value1 :sqlStmt :*on)
c                   callp     replaceTag('FIELD4' :value1 :sqlStmt :*on)
c                   callp     replaceTag('FIELD5' :value1 :sqlStmt)     


Above is assuming that you already has a export procedure call
replaceTag that can replace the tag with the actual value.  The
prototype would look something like this:
p replaceTag      B                                          
d                 pi            10i 0                        
d  piTag                        30    varying const          
d  piValue                   32767    options(*varsize) const
d  piSource                  32767    options(*varsize)      
d  piAddQuote                     n                          




-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Matt Gross
Sent: Sunday, August 20, 2006 3:22 PM
To: Post AS-400 Language Questions
Subject: Include Numeric Field in SQL String

I have a need to pass a string to a procedure that will execute an SQL
statement.
   
  Is there a way to include a numeric field with this?  I've tried a few
things, buy they've been unsuccessful.  I've done this is the past, but
can't locate the example.
   
  In the below example, fields 2 and 5 are numeric.  This example fails:
   
  c                   eval      sqlstmt = %trim(sqlstmt) +
c                             %trim(insert) + ' ' +     
c                             ' ' + %trim(filnam) +     
c                             ' ' + %trim(fields ) +    
c                             ' VALUES(' +              
c                             Q + Value1 + Q + ',' +    
c                             Value2 +                  
c                             Q + Value3 + Q + ',' +    
c                             Q + Value4 + Q + ',' +    
c                             Value5 +')'               
   
   
  TIA,
   
  Matt
--
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 ...


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.