dbTalk Databases Forums  

Calling functions - NULL vs default

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Calling functions - NULL vs default in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
PhilHibbs
 
Posts: n/a

Default Calling functions - NULL vs default - 07-17-2006 , 04:32 AM






In an Oracle function or procedure call, there can be parameters that
have defaults, such as language code. If NULL is passed, this overrides
the default. What I want to do is to create a table that mirrors the
function's parameter list and call the function using the rows in that
table, but I don't want to override defaults with NULLs. How can I do
this? Is dynamically generating a function call the only way? Might
this cause a significant performace hit, for instance if I were
creating thousands of employees through the HRMS create_employee API?

Phil Hibbs.


Reply With Quote
  #2  
Old   
Martin T.
 
Posts: n/a

Default Re: Calling functions - NULL vs default - 07-18-2006 , 06:28 AM






PhilHibbs wrote:
Quote:
In an Oracle function or procedure call, there can be parameters that
have defaults, such as language code. If NULL is passed, this overrides
the default. What I want to do is to create a table that mirrors the
function's parameter list and call the function using the rows in that
table, but I don't want to override defaults with NULLs. How can I do
this? Is dynamically generating a function call the only way? Might
this cause a significant performace hit, for instance if I were
creating thousands of employees through the HRMS create_employee API?

Phil Hibbs.
Hmm ... do you want a function that ignores NULL parameters (if NULL is
passed or parameter is not passed, default value is used) or do you
want a function with 'normal' default parameters?
As I see it you can have a function that does one of both things, but
not one(1) function that does both.

best,
Martin



Reply With Quote
  #3  
Old   
Thomas Sommerfeld
 
Posts: n/a

Default Re: Calling functions - NULL vs default - 07-18-2006 , 05:00 PM



PhilHibbs wrote:
Quote:
In an Oracle function or procedure call, there can be parameters that
have defaults, such as language code. If NULL is passed, this overrides
the default. What I want to do is to create a table that mirrors the
function's parameter list and call the function using the rows in that
table, but I don't want to override defaults with NULLs. How can I do
this? Is dynamically generating a function call the only way? Might
this cause a significant performace hit, for instance if I were
creating thousands of employees through the HRMS create_employee API?

Phil Hibbs.

Hi Phil,

what a about testing the parameters in the function body and assign
default values to local variables if a parameter is NULL?
Something like:
function ProcessRow(Col1 in MyTable.Col1%Type, Col2 in
MyTable.Col2%Type, ...) return number is
vCol1 MyTable.Col1%Type;
vCol2 MyTable.Col2%Type;
begin
if Col1 is null then
vCol1 := DefaultValueCol1;
else
vCol1 := Col1;
end if;
if Col2 is null then
vCol2 := DefaultValueCol2;
else
vCol2 := Col2;
end if;
...
end;

Best regards
Thomas

--
For answers by personal mail use: thomas.sommerfeld at domain ust-gmbh.de


Reply With Quote
  #4  
Old   
PhilHibbs
 
Posts: n/a

Default Re: Calling functions - NULL vs default - 07-19-2006 , 04:51 AM



Thomas Sommerfeld wrote:
Quote:
Hi Phil,

what a about testing the parameters in the function body and assign
default values to local variables if a parameter is NULL?
That's fine for my own functions, but I want to call HRMS API functions
that have defaults. I want to be able to specify the arguement, but
pass "nothing" in so that the default takes precedence.

The HRMS Data Pump White Paper says that DP works this way - you can
leave a column in the DP table as NULL and the default will override
the NULL - so I looked in the implementation and couldn't see anything
clever that implemented this behaviour, and when I tested it, the NULL
in the table is what got used and not the default. In other words, the
white paper LIES about this! It says it does what I was wanting to do,
but in fact does not! This implies to me that this is a difficult thing
to do (maybe the author of the WP wanted to implement this feature, but
it proved too difficult or slow and so was removed).

Phil Hibbs.



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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.