Re: Error when creating function in psotgresql 8.1

From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: ben sewell <mosherben(at)gmail(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Error when creating function in psotgresql 8.1
Date: 2006-08-17 15:04:48
Message-ID: C109FDD0.F9D6%sdavis2@mail.nih.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 8/17/06 10:48 AM, "ben sewell" <mosherben(at)gmail(dot)com> wrote:

> Hi Sean,
> that's fine I'll google it later the time when I need it.
>
> Sorry but I got another question about my procedure, I have my parameters
> coming from the access forms which can be left empty (aka null).
>
> I'll need to create handling for when the parameters are null so this would
> be using if statements. Once I've handled the input parameters the select
> into queries will be run. Here's the pseudocode code for it so I was
> wondering if you could tell me the equilivent for it in postgres.
>
> if adviser_id=null then
> all records are returned irrespective if the adviser_id
> else
> find records which the adviser_id matches
> endif;

You may want to do something along the lines of:

http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGS
QL-STATEMENTS-EXECUTING-DYN

Building the query a piece at a time and then executing. Alternatively, you
can also create multiple functions with different prototypes (different
parameter types) so that you could have a function like:

My_func(int,int) ....

And

My_func(int)

The two functions, although they have the same name, are different and can
do different things.

Sean

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Mike Nees 2006-08-17 19:45:15 Re: COPY command
Previous Message Richard Broersma Jr 2006-08-17 14:55:41 Re: Error when creating function in psotgresql 8.1