Solved

db2, sqlrpgle program, difficulties with sintax sql

Posted on 2011-03-07
3
816 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Expert Comment

by:Dave Ford
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 35

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

622 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