hi all,
please forgive me if this question is too naive. heres what i am trying to do:
i have a stored procedure that takes in an optional argument which defaults to null. if its null i have to return all the values from a table, else return only those values that have a value match against the given optional argument. so it will be something like this
opt_arg=null --The optional parameter
select * from table
where id in (select case when opt_arg is null
(select id from table)
else opt_arg)
the error i get here is:
"cannot return multiple values in a sub-query"
please note that i cannot write this as
if ( opt_arg is null)
select * from table
else
select * from table where id=opt_arg
because i take actually take in 5 optional arguments which can all be null, and cannot write all the permutations of these arguments.
thanks in advance.
lak.
please forgive me if this question is too naive. heres what i am trying to do:
i have a stored procedure that takes in an optional argument which defaults to null. if its null i have to return all the values from a table, else return only those values that have a value match against the given optional argument. so it will be something like this
opt_arg=null --The optional parameter
select * from table
where id in (select case when opt_arg is null
(select id from table)
else opt_arg)
the error i get here is:
"cannot return multiple values in a sub-query"
please note that i cannot write this as
if ( opt_arg is null)
select * from table
else
select * from table where id=opt_arg
because i take actually take in 5 optional arguments which can all be null, and cannot write all the permutations of these arguments.
thanks in advance.
lak.