niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle
Calling functions - NULL vs default
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
snarks@gmail.com
*nix forums beginner


Joined: 07 Jun 2006
Posts: 12

PostPosted: Mon Jul 17, 2006 9:32 am    Post subject: Calling functions - NULL vs default Reply with 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.
Back to top
Martin T.
*nix forums beginner


Joined: 07 Mar 2005
Posts: 39

PostPosted: Tue Jul 18, 2006 11:28 am    Post subject: Re: Calling functions - NULL vs default Reply with quote

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
Back to top
Thomas Sommerfeld
*nix forums beginner


Joined: 18 Jul 2006
Posts: 1

PostPosted: Tue Jul 18, 2006 10:00 pm    Post subject: Re: Calling functions - NULL vs default Reply with quote

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
Back to top
snarks@gmail.com
*nix forums beginner


Joined: 07 Jun 2006
Posts: 12

PostPosted: Wed Jul 19, 2006 9:51 am    Post subject: Re: Calling functions - NULL vs default Reply with quote

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.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Thu Nov 20, 2008 9:07 pm | All times are GMT
navigation Forum index » Databases » Oracle
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts change default install directory when using bdist_rpm krithika.sridhar@gmail.co python 1 Fri Jul 21, 2006 4:09 am
No new posts calling stored procedure using ECPG Jasbinder Bali PostgreSQL 1 Thu Jul 20, 2006 7:53 pm
No new posts does the default constructor initialize values? NewToCPP C++ 12 Thu Jul 20, 2006 3:37 pm
No new posts default route entry is missing. Rijesh Tru64 managers mail-list 0 Thu Jul 20, 2006 9:48 am
No new posts Error while calling an Oracle Stored Procedure from VB us... macca Server 5 Thu Jul 20, 2006 9:32 am

Mortgage Loans | Mortgages | Mortgage Calculator | Debt Consolidation | Western Union Money Transfer
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1672s ][ Queries: 16 (0.0844s) ][ GZIP on - Debug on ]