pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rod Taylor <rbt@rbt.ca>
To: Rado Petrik <r.p@szm.sk>
Cc: PostgreSQL-mailinglist <pgsql-sql@postgresql.org>
Subject: Re: What is bad in this query ?
Date: 02 May 2003 10:32:52 -0400
Message-ID: <1051885971.94424.29.camel@jester> (raw)
In-Reply-To: <1051881697.29275.14.camel@caj>
References: <1051881697.29275.14.camel@caj>

On Fri, 2003-05-02 at 09:21, Rado Petrik wrote:
> Hi, 
> 
> What is bad in this query ? 
> 
> SELECT CASE 
> 	WHEN EXIST(SELECT * FROM user WHERE name=rado) 
> 		THEN (INSERT INTO user VALUES('rado')) 
> 	END; 

The INSERT is bad.

Try something like:
INSERT INTO user (name)
	SELECT name FROM user WHERE name = 'rado';


-- 
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

Attachments:

  signature.asc (application/pgp-signature, 186B) download

view thread (4+ messages)  latest in thread

Message-ID: <1051885971.94424.29.camel@jester>
Permalink:  ../1051885971.94424.29.camel@jester/
Also on:    postgresql.org/message-id/1051885971.94424.29.camel@jester

 · 

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: rbt@rbt.ca, r.p@szm.sk
  Subject: Re: What is bad in this query ?
  In-Reply-To: <1051885971.94424.29.camel@jester>

* 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