1

I would like to know, if there is any possible way in SQL to distinguish which one of default parameters was set when function was called? F.e. if there is function:

CREATE OR REPLACE FUNCTION someFunction (
ID NUMBER,
showNames VARCHAR2 DEFAULT 'N',
showAddress VARCHAR2 DEFAULT 'N')

and it will be called like that:

someFunction(123, 'Y')

is there any way to distinguish which parameter was set by 'Y'? Or if I need to set showAddress to 'Y' do I have to call function like that:

someFunction(123, 'N', 'Y')
1
  • 2
    I'm tagging this question "oracle" because the use of varchar2 suggests Oracle. Commented May 5, 2014 at 10:46

3 Answers 3

4

if you use Oracle database you could specify exact param name:

   someFunction(123, showAddress =>'Y')
Sign up to request clarification or add additional context in comments.

Comments

1

Since this is tagged as Oracle; you can use named parameter like formal => actual. So in your case, you can say someFunction(123, shownames => 'Y') in which case ID and shownames will be set; whereas showaddress will have default value.

Otherwise, it's all positional parameter and hence calling someFunction(123, 'Y') will set ID and then shownames based on position of the parameters.

See more here

http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/subprograms.htm#LNPLS00825

Comments

0

After trying this method:

 someFunction(123, showAddress =>'Y')

I've got exception message: ORA-00907: missing right parentesis. This problem exist only when I am using showAddress =>'Y' - when I use just someFunction(123) everything works fine. Can it be caused by using old ORACLE version? (I am using 10.2 at the moment).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.