pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-sql@postgresql.org
Subject: Re: simple? query
Date: 14 Aug 2009 08:58:58 GMT
Message-ID: <h6390i$up9$3@reversiblemaps.ath.cx> (raw)
References: <E30C7040DE22624185BAD4093190B54437BE5DB4C1@EX2007-MBX-2.uz.kuleuven.ac.be>

On 2009-08-13, Jan Verheyden <jan.verheyden@uz.kuleuven.ac.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 );




view thread (12+ messages)  latest in thread

Message-ID: <h6390i$up9$3@reversiblemaps.ath.cx>
Permalink:  ../h6390i$up9$3@reversiblemaps.ath.cx/
Also on:    postgresql.org/message-id/h6390i$up9$3@reversiblemaps.ath.cx

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jasen@xnet.co.nz
  Subject: Re: simple? query
  In-Reply-To: <h6390i$up9$3@reversiblemaps.ath.cx>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox