Skip site navigation (1) Skip section navigation (2)

Re: simple? query

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: simple? query
Date: 2009-08-14 08:58:58
Message-ID: h6390i$up9$3@reversiblemaps.ath.cx (view raw or flat)
Thread:
Lists: pgsql-sql
On 2009-08-13, Jan Verheyden <jan(dot)verheyden(at)uz(dot)kuleuven(dot)ac(dot)be> wrote:
> --_004_E30C7040DE22624185BAD4093190B54437BE5DB4C1EX2007MBX2uzk_
> Content-Type: multipart/alternative;
> 	boundary="_000_E30C7040DE22624185BAD4093190B54437BE5DB4C1EX2007MBX2uzk_"
>
> --_000_E30C7040DE22624185BAD4093190B54437BE5DB4C1EX2007MBX2uzk_
> Content-Type: text/plain; charset="us-ascii"
> Content-Transfer-Encoding: quoted-printable
>
> Hi,
>
> I was trying to run following query but doesn't work:
>
> if (uid='janvleuven10') then
>                 insert into test (registered) values ('1');
> else
>                 insert into test (registered) values ('0');
> end if;

that's not SQL. (it could be plpgsql)

if you need to do it in SQL do this.

insert into test (registered) 
 values ( case when uid='janvleuven10' then '1' else '0' end );


In response to

pgsql-sql by date

Next:From: Hengky LieDate: 2009-08-14 09:20:58
Subject: Field or record level encryption / decryption
Previous:From: Adrian KlaverDate: 2009-08-13 23:30:41
Subject: Re: mail alert

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group