-
select statement base on user input
Hi all,
I have question about the sql statement to pass in the value into the where clause from the user input.
For instance:
in the user input screen, I have drop down box to select a value for a particular table. 10,20,30 and *
for example : scott.dept table I have deptno 10,20,30
if the user select '*', my sql satetment will 'intelligently' detect it needs all the 10,20,30 value for the deptno. If the user only select 10, it only select dept= 10, and so on.
Question is how to put it into a single sql select statement with such condition ? or the application level has to auto convert the '*' to '10,20,30'....??
Thanks...
-
Ok! I got the solution from one of friend in Internet.
select * from emp
where deptno in (decode('&dept_value','*',10),
decode('&dept_value','*',20),
decode('&dept_value','*',30),'&dept_value');
Enjoy!!
-
U can try this simple sql
select * from DEPT
where (DEPT_CODE = &P_DEPT_CODE OR
&P_DEPT_CODE = '*')
Hope this can help u
ching
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|