
February 4th, 2013, 02:45 PM
|
|
Contributing User
|
|
Join Date: Feb 2008
Posts: 76
Time spent in forums: 1 Day 1 h 42 m 42 sec
Reputation Power: 6
|
|
|
Multiple table insert involving sequences
Hi, I have a temp table and want to insert that data into 2 tables. In both of my tables i have a sequence column but in my second table its a foreign key to the main table
PHP Code:
$up_query="INSERT INTO AFFILIATE (FNAME,LNAME,EMAIL,PHONE,ORG,ADDRESS1,ADDRESS2,COUNTY_ID,AFF_ID)
Select a.FNAME, a.LNAME,a.EMAIL,a.PHONE, a.ORG, a.ADDRESS1, a.ADDRESS2,C.COUNTY_ID,'AF'||aff_seq.nextval
FROM temp_aff A LEFT OUTER JOIN COUNTY C
ON UPPER(A.COUNTY)=C.CNAME";
$up_query2= "INSERT INTO TEST4 (DEPT_ID,CAMP_ID,AFF_ID, PASSWD)
SELECT D.DEPT_ID,C.CAMP_ID,aff_seq.currval,'Zq'||dbms_random.string('A',4)||'$8' from dual,TEMP_AFF A
left outer join DEPT D ON (UPPER(A.DEPT)=UPPER(D.DNAME))
left outer join CAMPUS C ON (UPPER(A.CAMPUS)=UPPER(C.CPNAME))";
However in my test4 table its inserting the aff_seq.currval for all records. Its not incrementing as in the affiliate table.
I appreciate any suggestions which would help me resolve it
|