Unix Technical Forum

problems with default parameter values

This is a discussion on problems with default parameter values within the Oracle Miscellaneous forums, part of the Oracle Database category; --> using Oracle 10g (maybe others, I don't know) Writing Stored procs which have default values. I had a bunch ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-07-2008, 10:01 PM
kevin Sedota
 
Posts: n/a
Default problems with default parameter values

using Oracle 10g (maybe others, I don't know)
Writing Stored procs which have default values.

I had a bunch of code that had parameter definitions that looked like:

p1 in varchar2 := null,
p2 in number := null

These worked fine when the parameter was a varchar but for anything else it
would not work. I'm not sure what was being passed.
However if I coded

p1 in varchar2 DEFAULT null,
p2 in number DEFAULT null

everything worked fine. The documentation states that := should be use for
defining default numerics. something like

p2 in number := 7

which would seem to imply that null in place of 7 should be ok. But it's
not.

Is this an error in the documentation?

thanks

kjs


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-07-2008, 10:02 PM
Christian Antognini
 
Posts: n/a
Default Re: problems with default parameter values

**** Post for FREE via your newsreader at post.usenet.com ****

Hi Kevin

> These worked fine when the parameter was a varchar but for anything else

it
> would not work.


What does this mean? The default value was not used, you get an error or
something else....

> everything worked fine. The documentation states that := should be use for
> defining default numerics. something like
>
> p2 in number := 7
>
> which would seem to imply that null in place of 7 should be ok. But it's
> not.
>
> Is this an error in the documentation?


According to the documentation both can be used.
http://download-west.oracle.com/docs...htm#sthref1788

Chris



-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
http://www.usenet.com
Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-07-2008, 10:02 PM
george lewycky
 
Posts: n/a
Default Re: problems with default parameter values

Maybe using CONSTANT would help your situation......
Its unclear whether you meant parameter(can change) or constant (doesnt change)


cn_item_text_length CONSTANT NUMBER(2) := 69;
cn_item_amount_length CONSTANT NUMBER(2) := 19;

good luck

george


"Christian Antognini" <christian.antognini@trivadis.com> wrote in message news:<4111e4f3$1@post.usenet.com>...
> **** Post for FREE via your newsreader at post.usenet.com ****
>
> Hi Kevin
>
> > These worked fine when the parameter was a varchar but for anything else

> it
> > would not work.

>
> What does this mean? The default value was not used, you get an error or
> something else....
>
> > everything worked fine. The documentation states that := should be use for
> > defining default numerics. something like
> >
> > p2 in number := 7
> >
> > which would seem to imply that null in place of 7 should be ok. But it's
> > not.
> >
> > Is this an error in the documentation?

>
> According to the documentation both can be used.
> http://download-west.oracle.com/docs...htm#sthref1788
>
> Chris
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
> http://www.usenet.com
> Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-07-2008, 10:02 PM
kevin Sedota
 
Posts: n/a
Default Re: problems with default parameter values

I can only presume that I was getting something else. The default value was
null and no value was passed in from the c# .Net program or the value was
explicitly set to null. However the condition failed when it should not
have. we generally code things like

create or replace procedure
( param in number := null
param2 in number DEFAULT null)
as
SELECT col1,col2
FROM sometable
WHERE ((param is null) OR (param = col1))
AND ((param is null) OR (param = col2))

In this case the version that had the param coded with the := behaved
differently than the one coded with DEFAULT.


"Christian Antognini" <christian.antognini@trivadis.com> wrote in message
news:4111e4f3$1@post.usenet.com...
> **** Post for FREE via your newsreader at post.usenet.com ****
>
> Hi Kevin
>
> > These worked fine when the parameter was a varchar but for anything else

> it
> > would not work.

>
> What does this mean? The default value was not used, you get an error or
> something else....
>
> > everything worked fine. The documentation states that := should be use

for
> > defining default numerics. something like
> >
> > p2 in number := 7
> >
> > which would seem to imply that null in place of 7 should be ok. But it's
> > not.
> >
> > Is this an error in the documentation?

>
> According to the documentation both can be used.
>

http://download-west.oracle.com/docs...htm#sthref1788
>
> Chris
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
> http://www.usenet.com
> Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:30 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com