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 

Using ',' instead of ':' for Host variables in DB2

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
ravi.alpha
Beginner


Joined: 31 Mar 2009
Posts: 18
Topics: 7

PostPosted: Mon Apr 13, 2009 4:22 am    Post subject: Using ',' instead of ':' for Host variables in DB2 Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Apr 13, 2009 6:06 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Mon Apr 13, 2009 6:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
ravi.alpha
Beginner


Joined: 31 Mar 2009
Posts: 18
Topics: 7

PostPosted: Mon Apr 13, 2009 11:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Apr 14, 2009 2:11 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database 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