Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to pass two input parameter to a query string in oracle

Posted on 2003-03-20
3
Medium Priority
?
806 Views
Last Modified: 2012-05-04
hi ,
I have two input parameters in my sql query. I placed the sql statement in a string. Now i have two compare two input parameter values with two columns. Please provide me a example to solve my problem. My input parameters are strings.

with rgds,
venkat

Eg: strsql := 'select empno, empname from emp where emp_no = '||strInputpar1||' and empname = '||strippar2||''and dept is not null;

Like above i written the query. It is not giving the values.
0
Comment
Question by:ponnuruv
  • 2
3 Comments
 
LVL 1

Expert Comment

by:mona1974
ID: 8173049
The string should be between ' ' characters.

To have this in a string you should use twice the character ' (ex: '') + 'character for delimiting string
Example

select 'Scott' from dual has as result Scott
select '''Scott''' from dual has as result 'Scott'.

So:

strsql := 'select empno, empname from emp where emp_no = ''' ||strInputpar1|| ''' and empname = '''||strippar2||'''and dept is not null
0
 
LVL 1

Accepted Solution

by:
mona1974 earned 90 total points
ID: 8173056
sorry, for emp_no you don't need ''.
So:
strsql := 'select empno, empname from emp where emp_no = ' ||strInputpar1|| ' and empname = '''||strippar2||'''and dept is not null
0
 

Author Comment

by:ponnuruv
ID: 8179277
Thanks for ur timely help.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question