If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Input parameter value while executing SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-31-06, 14:44
jinsezh jinsezh is offline
Registered User
 
Join Date: Aug 2006
Posts: 33
Question Input parameter value while executing SQL

Hi there,

In oracle, if I run

select * from employer where emplorer name like &EmpName;

the system will prompt me to input the value for parameter 'EmpName'.

Is there any way in DB2 I can do the same thing?


Thanks,
Jinsezh
Reply With Quote
  #2 (permalink)  
Old 08-31-06, 15:39
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
I assume you mean in the CLP. THe answer is no.

Andy
Reply With Quote
  #3 (permalink)  
Old 08-31-06, 20:46
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
That does work with the QMF query tool for DB2 for z/OS (which I am sure is where Oracle stole it from). But it is not really the Oracle database engine, but the Oracle SQL+ interface that does that.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #4 (permalink)  
Old 09-03-06, 03:19
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
On unix or linux (or any OS where you can install and run bash) the following shell script does roughly what you want:
Code:
#! /bin/bash
echo "Enter EmpName (may include '%' or '_' wildcards): \c"
read EmpName
db2 select \* from employer where employer_name like $EmpName
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #5 (permalink)  
Old 09-05-06, 18:01
jinsezh jinsezh is offline
Registered User
 
Join Date: Aug 2006
Posts: 33
Thank you all.

I found it in QMF, the query is exactly the same as in Oracle, the parameter also declares with &.

Cheers,
jinsezh
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On