View previous topic :: View next topic |
Author |
Message |
danm Intermediate
Joined: 29 Jun 2004 Posts: 170 Topics: 73
|
Posted: Thu Apr 29, 2010 10:49 am Post subject: Pre-Processor variable |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Apr 29, 2010 10:56 am Post subject: |
|
|
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 |
|
 |
|
|