Re: pl/pgsql and controling loops

From: aklaver(at)comcast(dot)net (Adrian Klaver)
To: "Alain Roger" <raf(dot)news(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: pl/pgsql and controling loops
Date: 2008-03-27 19:13:44
Message-ID: 032720081913.19231.47EBF1E8000D791600004B1F22007374789D0A900E04050E@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


-------------- Original message ----------------------
From: "Alain Roger" <raf(dot)news(at)gmail(dot)com>
> Hi,
>
> i've read several books extract about controlling loops in postgreSQL under
> pl/pgsql and there is something interesting.
>
> once to do a comparison they use :
>
> > IF (ret == 1) THEN ...
>
>
> once,
>
> > IF (ret = 1) THEN...
>

Both are correct.

>
> so are they both correct ?
> comming from .NET/C++ world, usually we use '==' or '!=', so i expect that
> correct ones are '==' and '<>'.
>
> moreover, when i check if the returned value "ret_email" from SELECT email
> INTO ret_email FROM tmp_newsletterreg WHERE tmp_usr_id = id_session;
> i want to check if it is empty or not, so i do IF(ret_email <> '' ) THEN...
> but it does not work... every time it enter in the loop, even if it is empty
> string.
>
> where is the problem ?

Are you sure ret_email is an empty string and not a NULL value. <> won't work on a NULL value. You will need to use IS NULL or IS NOT NULL.
>
> thx.
>
> --
> Alain
> ------------------------------------
> Windows XP SP2
> PostgreSQL 8.2.4 / MS SQL server 2005
> Apache 2.2.4
> PHP 5.2.4
> C# 2005-2008

--
Adrian Klaver
aklaver(at)comcast(dot)net

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alain Roger 2008-03-27 19:43:46 dunction issue
Previous Message Alain Roger 2008-03-27 19:03:32 pl/pgsql and controling loops