Re: Help with prepared statement

From: Bendik Rognlien Johansen <bendik(dot)johansen(at)gmail(dot)com>
To: Jan B(dot) <jan(at)monso(dot)de>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Help with prepared statement
Date: 2005-05-24 07:21:46
Message-ID: E0106DC2-C853-4E64-8781-DF8319C7BBB9@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Thank you that solved my problem!

On May 23, 2005, at 6:12 PM, Jan B. wrote:

> I have a suggestion for a workaround:
> What about using the following expression for comparison:
>
> WHERE (id=$1 OR (id ISNULL AND $1 ISNULL))
>
> Probably it will have a negative impact on performance.
>
> Jan Behrens
>
>
> Bendik Rognlien Johansen wrote:
>
>> Hello,
>> I am having some difficulty using a prepared statement.
>> PREPARE fooplan(int4, int4) AS SELECT * FROM records WHERE id =
>> $1 AND fax = $2;
>> Normally this works fine like this:
>> EXECUTE fooplan(42985, 12345678);
>> However, sometimes I need to match NULL values like this:
>> EXECUTE fooplan(42985, NULL);
>> This fails of course since "fax = NULL" is not the same as "fax
>> IS NULL".
>> Is there any way around this?
>> Thanks!
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 3: if posting/reading through Usenet, please send an appropriate
>> subscribe-nomail command to majordomo(at)postgresql(dot)org so that
>> your
>> message can get through to the mailing list cleanly
>>
>
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Agustín Caminero Herráez 2005-05-24 07:50:56 A question about postmaster and postgresql commands
Previous Message tövis 2005-05-24 06:38:53 Re: "NOT NULL"