pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jasiek@klaster.net
To: alexj <alexj@freesurf.ch>
Cc: pgsql-sql@postgresql.org
Subject: Re: trouble with query
Date: Wed, 19 Mar 2003 19:49:27 +0100
Message-ID: <20030319184927.GA29082@serwer.skawsoft.com.pl> (raw)
In-Reply-To: <3e7731a9$0$1051$5402220f@news.sunrise.ch>
References: <3e7731a9$0$1051$5402220f@news.sunrise.ch>

On Tue, Mar 18, 2003 at 03:47:55PM +0100, alexj wrote:
> Hi,
> 
> I'm looking how can I do to insert multiple values from a
> complexe query.
> 
> What I want to do is something like that :
> 
> INSERT INTO est_planifie_jour (id,ref_activite,ref_ressource,ref_jour)
>  (SELECT nextval('est_p_id_p') FROM est_planifie),
>  (SELECT id_activite FROM activite WHERE
>  nom = 'SGBD 02 cours théorique),
> (SELECT ref_ressource FROM personne,groupe,fait_partie
>  WHERE groupe.nom ='cycle 1b' AND
>  fait_partie.ref_groupe = groupe.id_groupe AND
> personne.id_personne = fait_partie.ref_personne),
> (SELECT id_jour FROM jour WHERE jour.id_jour = 3)
>
You should rewrite your insert to receive multiple rows from single
select. This query shoud be similiar to this below:

insert into ... (..)
select
 nextval('est_p_id_p'),
 id_activite,
 ref_resource,
 ref_jour
from
 activite, personne,groupe,fait_partie,jour
where
 activite.nom='..' and fait_partie.ref_groupe=groupe.id_groupe
 and groupe.nom='..'
 and jour.id_jour=3

Regards,
Tomasz Myrta



view thread (2+ messages)

Message-ID: <20030319184927.GA29082@serwer.skawsoft.com.pl>
Permalink:  ../20030319184927.GA29082@serwer.skawsoft.com.pl/
Also on:    postgresql.org/message-id/20030319184927.GA29082@serwer.skawsoft.com.pl

 · 

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: jasiek@klaster.net, alexj@freesurf.ch
  Subject: Re: trouble with query
  In-Reply-To: <20030319184927.GA29082@serwer.skawsoft.com.pl>

* 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