MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pre-Processor variable

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Thu Apr 29, 2010 10:49 am    Post subject: Pre-Processor variable Reply with quote

I would like to set the DB2 table name as a variable. In the example below, I need to declare two variables, TABLE1 and TABLEA with the same value ('USERA.TABLEXYZ'). Can a single variable be used?

Code:

DCL SqlCmd CHAR(100) VARYING INIT(' ');
DCL TABLE1 CHAR(25) VARYING INIT('USERA.TABLEXYZ');

/* Declare pre-processor variable */
%DCL TABLEA CHARACTER;
%TABLEA = 'USERA.TABLEXYZ';
...
....
SqlCmd = "Select from " || TABLE1 || "..."
EXEC SQL SELECT COL1, COL2 INTO :COLA, :COL2 FROM TABLEA
  WHERE .....;

Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Apr 29, 2010 10:56 am    Post subject: Reply with quote

danm,

Why define the tablea and table1? Dynamically prepare the SQLCMD and use the table name.

or just define 1 variable and move the table name into it.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group