Solved

db2, sqlrpgle program, difficulties with sintax sql

Posted on 2011-03-07
3
805 Views
Last Modified: 2012-05-11
Hi,
I'm programming with sqlrpgle,
I have some syntax problem..
look at this:
C*                                                                      
c     *entry        plist                                                
c                   parm                    fromart          13          
c                   parm                    toart            13          
C/EXEC SQL                                                              
c+ with tmp as                                                          
c+ ( select * from qs36f/artordimp                                      
c+ where i$pn between :fromart and :toart)                              
c+                                                                      
C+ create table qs36f/ordcli as                                          
C+ (tmp)                                                                
C+ with data                                                            
C/END-EXEC                                                              
C                   SETON                                        LR      

How to use "with" statment and "create_table" in the same program?
I decide to use "with statment" only beacuse the compiler says
that I cannot use parameters in "create table" statment,
How to make this program work?
0
Comment
Question by:bobdylan75
3 Comments
 
LVL 18

Expert Comment

by:daveslash
ID: 35059303

The following works beautifully for me on V6R1.

HTH,
DaveSlash



create table qtemp/deleteme as (           
  select *                                 
    from qtemp/tmtiers                     
   where TIERLETTER in ('S', 'M', 'F', 'C')
  with nc
) with data

Open in new window

0
 
LVL 34

Accepted Solution

by:
Gary Patterson earned 500 total points
ID: 35061150
Try using dynamic sql to get around the variable limitation:


d sqlString       s          32000a   varying 

c     *entry        plist                                                
c                   parm                    fromart          13          
c                   parm                    toart            13          

c                   eval      sqlString = 'with tmp as ' +                                                          
c                             '(select * from qs36f/artordimp ' +                                      
c                             ' where i$pn between ' + 
c                               fromart + ' and ' + toart + ') ' +                              
C                              'create table qs36f/ordcli as (tmp)' +
c                              'with data'                                                       

c/exec sql
c+                  execute immediate :sqlString
c/end-exec

Open in new window

0
 

Author Comment

by:bobdylan75
ID: 35066855
Thank you Gary.. I will try it in the next hour...
see you later...
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now