Thread: Function declaration

Function declaration

From
"A. Kulikov"
Date:
Is there a possiblity to declare functions with optional parameters
i.e. in case some parameters are not passed to the function, then some
kind of default value is assigned to the function?

regards,

alex
--
The mind is essential -- http://essentialmind.com/


Re: Function declaration

From
"Sean Davis"
Date:
Alex,

What happens if you declare your function as:

function(text,text)

or whatever your datatypes for each argument are supposed to be and then, 
within your function, test whether the arguments are NULL?  I haven't tried 
it, so I can't say for sure, but it seems like you should be able to pass a 
SQL NULL as an argument.

Sean

----- Original Message ----- 
From: "A. Kulikov" <a.kulikov@gmail.com>
To: "Sean Davis" <sdavis2@mail.nih.gov>
Sent: Monday, April 18, 2005 8:44 PM
Subject: Re: [SQL] Function declaration


Unfortunately that is not what I am looking for =( Although the task I
have in mind can be accomplished using overloading. Is there no
equivalent in plpgsql for

function(foo,bar=null)...

??

regards,

alex

2005/4/19, Sean Davis <sdavis2@mail.nih.gov>:
> Alex,
>
> I think what you are looking for is called function overloading.  See the
> documenation here:
>
> http://www.postgresql.org/docs/8.0/interactive/xfunc-overload.html
>
> Sean
>
> ----- Original Message -----
> From: "A. Kulikov" <a.kulikov@gmail.com>
> To: <pgsql-sql@postgresql.org>
> Sent: Monday, April 18, 2005 8:28 PM
> Subject: [SQL] Function declaration
>
> Is there a possiblity to declare functions with optional parameters
> i.e. in case some parameters are not passed to the function, then some
> kind of default value is assigned to the function?
>
>


-- 
The mind is essential -- http://essentialmind.com/