-
I started studying SQL Loader today, I need to insert like thousands of rows to several tables. I guess SQL Loader is the best way to do this (???)
The first problem I encoutered is the following and I hope that someone could advice me on this:
If I use the following to insert data to "customer" table:
LOAD DATA
INFILE *
APPEND
INTO TABLE customer
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
( cust_name,
cust_address,
cust_id "custid_seq.nextval"
)
BEGINDATA
"Customer 1","Address 1"
"Customer 2","Address 2"
Then, how can I use the primary key's values (cust_id - created from the sequence) in another table (I insert
data to this other table via another .ctl file), where this field is a foreign key? In other words, if the generated cust_id is, e.g. 100, then how can I automatically get this number to be inserted to the other table?
-
Simple create temporary tables. get the data into the db and then manipulate with sql.
Might not be the most elegant or effiecent way but when "learning on the job" sometimes you need to do the real basics to get the job done. You then have time to research.
Grah,
You'll always learn something if you take your time to ask.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|