Saravanan's Link Blog..!
தீதும் நன்றும் பிறர் தர வாரா
Google
asjs.blogspot.com geocities.com/asjsaravanan
Tuesday, November 23, 2004

Multi-table insert : Oracle 9i or higher
1. Conditional Multi-table insert :
INSERT ALL
WHEN (period=6) THEN
INTO course_6 (course_name, period) values(course_name, period)
WHEN (period=3) THEN
INTO course_3 (course_name, period) values(course_name, period)
ELSE
INTO course_other (course_name, period) values(course_name, period)
SELECT course_name, period FROM course;
What does the above query do ?
1. Insert courses for period 6 into the table named COURSE_6.
2. Insert courses for period 3 into the table named COURSE_3.
3. Insert all other courses into the table named COURSE_OTHER
4. The ALL keyword causes Oracle to check each row returned by the SELECT query against each WHEN clause. If a row satisfies more than one WHEN clause, it is inserted into more than one table. Use the FIRST keyword to limit inserts to only the first matching WHEN clause.
2. Unconditional Multi-table insert :
INSERT ALL
INTO courses_taken (course_name) values (course_name)
INTO students_registered (student_name) values (student_name)
SELECT course_name, student_name
FROM enrollment;
Comments: Post a Comment


I blog some of the interesing things i read on the web
Archives
12/01/2003 - 01/01/2004
01/01/2004 - 02/01/2004
02/01/2004 - 03/01/2004
03/01/2004 - 04/01/2004
04/01/2004 - 05/01/2004
05/01/2004 - 06/01/2004
06/01/2004 - 07/01/2004
07/01/2004 - 08/01/2004
08/01/2004 - 09/01/2004
09/01/2004 - 10/01/2004
10/01/2004 - 11/01/2004
11/01/2004 - 12/01/2004
12/01/2004 - 01/01/2005
01/01/2005 - 02/01/2005
02/01/2005 - 03/01/2005
03/01/2005 - 04/01/2005
04/01/2005 - 05/01/2005
05/01/2005 - 06/01/2005
06/01/2005 - 07/01/2005
07/01/2005 - 08/01/2005
08/01/2005 - 09/01/2005
09/01/2005 - 10/01/2005
10/01/2005 - 11/01/2005
11/01/2005 - 12/01/2005
12/01/2005 - 01/01/2006
01/01/2006 - 02/01/2006
02/01/2006 - 03/01/2006
03/01/2006 - 04/01/2006
12/01/2006 - 01/01/2007
04/01/2009 - 05/01/2009
Site Feed (Atom)
Subscribe with Bloglines