Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Inserting with Foreign Key
Hi all,
I've got some problems inserting records with a scripts in SQL.
The following code runs OK because composanteID is a primary Key and categorieID is a foreign Key:
insert into composantes
( composanteid, categorieid,
codelieux, nom, description, quantitestock, minimumstock
RefIdCat, 'A3#1', 'composante21', 'descrpcs21', 100, 25
from categories
) RefCategories
);
commit;
Here's should be the same logic to insert the records with 2 foreign keys:
insert into composantesprojets
( composanteid, projetid,
qterequise, qtebrisee, qtedefectueuse
)
(
Select PcsPrj,
RefPrj, 5, 0, 0
from projets
) RefProjet
);
Here's the select that's running OK:
SQL> Select PcsPrj,
2 RefPrj, 3 5, 4 0, 5 0
8 select min(composanteid) PcsPrj 9 from composantes
PCSPRJ REFPRJ 5 0 0 ---------- ---------- ---------- ---------- ----------
1 106 5 0 0
I want to include this record in a table
Here's the code for inserting:
SQL> insert into composantesprojets
2 ( composanteid, projetid, 3 qterequise, qtebrisee, qtedefectueuse 4 )
7 RefPrj, 8 5, 9 0, 10 0
13 select min(composanteid) PcsPrj 14 from composantes
Any clues??
Thanks in advance! Received on Wed Dec 05 2001 - 22:39:21 CST
![]() |
![]() |