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 ... (..)
selectnextval('est_p_id_p'),id_activite,ref_resource,ref_jour
fromactivite, personne,groupe,fait_partie,jour
whereactivite.nom='..' and fait_partie.ref_groupe=groupe.id_groupeand groupe.nom='..'and jour.id_jour=3
Regards,
Tomasz Myrta