View previous topic :: View next topic |
Author |
Message |
ravi.alpha Beginner
Joined: 31 Mar 2009 Posts: 18 Topics: 7
|
Posted: Mon Apr 13, 2009 4:22 am Post subject: Using ',' instead of ':' for Host variables in DB2 |
|
|
Hi,
We use DB2 V7. I have observed a different way of using SQLs
The SQL is
Code: |
Select Emp_ID,Dep_ID,Emp_Name,Dep_Name into
:WS-Emp-ID
,WS-Dep-ID
,Emp_Name
,Dep_Name
From Table1 where Emp_ID = 123456
|
In this instead of using ':' for all the host variable they are using ',' except for first
host variable WS-Emp-ID. This SQL is working fine in our system.
Just wondering how it is working, Is this a proper syntax? |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12381 Topics: 75 Location: San Jose
|
Posted: Mon Apr 13, 2009 6:06 pm Post subject: |
|
|
ravi.alpha,
I am going to make an educated guess that EMP_NAME and DEP_NAME are a part of a COPY Book which has COPY REPLACING which adds the Colon.
A colon (: ) must precede host variables that are used in SQL statements so DB2 can distinguish a variable name from a column name
Kolusu |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Mon Apr 13, 2009 6:38 pm Post subject: |
|
|
colons have been required for host variables since v6.
the commas are necessary to separate the items in the select list, the into list, the from list, order by....
and are not being interpreted by db2 as colons.
the last two items in the select into list (EMP_NAME and DEP_NAME as kolusu said) are column names without the colon.
I don't believe you when you say the 'quoted' SQL works. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
ravi.alpha Beginner
Joined: 31 Mar 2009 Posts: 18 Topics: 7
|
Posted: Mon Apr 13, 2009 11:16 pm Post subject: |
|
|
This is a production code which is running without any problems from many years.
I have just changed column names other than that SQL is just as I have mentioned.
I am wondering how it is working? |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Apr 14, 2009 2:11 am Post subject: |
|
|
Quote: | without any problems from many years. |
prior to version v6 possibly.
old dbrm's often will work with newer version of db2.
show us the dbrm, please. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
|
|