From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | ken(at)kencorey(dot)com |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Advice on stored proc error handling versus Sybase? |
Date: | 2001-01-09 06:36:04 |
Message-ID: | 174.979022164@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice |
Ken Corey <ken(at)kencorey(dot)com> writes:
> Questions:
> 1) Can I default arguments to the stored proc when the proc is defined?
We don't have default arguments for functions --- that wouldn't interact
too well with function-name overloading (which is the feature whereby
you can have multiple functions of the same name, so long as they have
different argument lists). You could work around this by defining some
convenience functions, eg
create function myfunc(a,b,c) as 'do the full job'
create function myfunc(a,b) as 'select myfunc(a,b,default-for-c)'
create function myfunc(a) as 'select myfunc(a,default-for-b,default-for-c)'
> 2) Can I explicitly name the args when the function is called, so that I
> could
> call this function as "select into ret I_PLAYER(@team_supported = 'My
> Team')"?
Not at the moment. This has been suggested before, and I suppose
someone might get around to it someday...
> 3) What if the insert fails? How can I tell?
You don't have to, because the function won't get to execute any further
if there's an error. AFAIK there's not yet any provision for trapping
errors in plpgsql. You might want to try the select first, and only
do the insert if the select doesn't find a match.
> 4) is there an 'isnull(value,substitute)' function predefined?
I think what you are looking for is COALESCE(). If that's not quite
right, build what you want out of spare parts using CASE. See
http://www.postgresql.org/devel-corner/docs/postgres/functions-conditional.htm
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-01-09 07:00:55 | Re: WAL questions |
Previous Message | Bruce Momjian | 2001-01-09 06:09:37 | Re: Doesn't use index, why? |
From | Date | Subject | |
---|---|---|---|
Next Message | Ken Corey | 2001-01-09 12:01:02 | Re: Advice on stored proc error handling versus Sybase? |
Previous Message | Anthony E . Greene | 2001-01-08 23:12:40 | Re: backup |