Home » RDBMS Server » Server Administration » default patameter
default patameter [message #57046] Fri, 16 May 2003 09:19 Go to next message
Eugene
Messages: 44
Registered: August 2001
Member
Hi all,
I have a procedure which takes no parameters. Some times I need to run that same procedure with one or two parameters. They will by used in the cursor, which produces the output. If I can say something like:

create procedure Z(x IN varchar2 default := ''
y IN varchar2 default := '') as
cursor aaa is
select ....
from .....
where ???? HOW DO I HANDLE IT IF PARAMS ARE NULLS
begin
some other statements
.....................
end Z;

then how do I deal with NULL parameters?
What is the "best" way to reuse that code?

Thanks,
Eugene
Re: default parameter [message #57048 is a reply to message #57046] Fri, 16 May 2003 11:54 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
One option:

create procedure z
  (x in varchar2 default null,
   y in varchar2 default null)
as
  cursor csr is
    select ...
      from ...
     where c1 = nvl(x, c1)
       and c2 = nvl(y, c2);
begin 
  ...
end;
/
Re: default parameter [message #57071 is a reply to message #57048] Mon, 19 May 2003 09:16 Go to previous message
Eugene
Messages: 44
Registered: August 2001
Member
Thanks Todd, it works

Eugene
Previous Topic: User quotas on Tablespace
Next Topic: Diff between Global database name(DB_NAME) and SID(INSTANCE_NAME)
Goto Forum:
  


Current Time: Mon Dec 30 17:35:32 CST 2024