URGENT: Inserting into two tables
Posted on 2004-10-12
To all experts!
How do I write a query to insert into two tables? The problem is that I am importing a CSV Unit Table file which contains only the Unit_number, Unit_name and School_name. FYI I will be putting this query into my ADOQuery component.
Firstly,it will need to insert the unit_number and unit_name into the unit table. Then it will have to check if the school name exsists in school table. If it exsists [e.g.School of Marketing] then it will take its school_id [e.g.01] and insert into the Unit_Table_School_id. If it does not exsists [e.g.School of Mangement] then it will insert the school name into school table thus generating the sequential number(which is already in that oracle table) and taking that sequential number [e.g. 02] and put it in Unit_Table_School_id.
-School_id(PK) [e.g. 01]
-School_name [e.g.School of Marketing]
-Unit_id(PK) [e.g. 001]
-Unit_number [e.g. 123456]
-Unit_name [e.g. Business Communication 100]
-Description [e.g.How to yak and yak]
-School_id(fk) [e.g. 01]