incorporate a sequence in control file

Can we incorporate a sequence in control file.
while working with sqlldr.
My need is to populate a column with a sequence when the dat file is loaded into the table.

Thanks
surendranadhAsked:
Who is Participating?
 
schwertnerConnect With a Mentor Commented:
Suppose you want to load the following department names into the dept table.
Each input record contains three department names, and you want to generate the
department numbers automatically.
Accounting Personnel Manufacturing
Shipping Purchasing Maintenance
...
You could use the following control file entries to generate unique department
numbers:
INTO TABLE dept
(deptno SEQUENCE(1, 3),
dname POSITION(1:14) CHAR)
INTO TABLE dept
(deptno SEQUENCE(2, 3),
dname POSITION(16:29) CHAR)
INTO TABLE dept
(deptno SEQUENCE(3, 3),
dname POSITION(31:44) CHAR)
The first INTO TABLE clause generates department number 1, the second number 2,
and the third number 3. They all use 3 as the sequence increment (the number of
department names in each record). This control file loads Accounting as department
number 1, Personnel as 2, and Manufacturing as 3.
The sequence numbers are then incremented for the next record, so Shipping loads
as 4, Purchasing as 5, and so on.
0
 
Mark GeerlingsDatabase AdministratorCommented:
Another option is to write a pre-insert trigger that selects the next value from the sequence and assigns it to the column you need populated.  This works as long as you are not using the "direct path" option of SQL*Loader.
0
 
pennnnConnect With a Mentor Commented:
I think you can use the database sequence within the control file. Example:
INTO TABLE dept
(deptno "schema_name.seq_name.NEXTVAL",
dname POSITION(1:14) CHAR)

We are using that syntax and it works!
Hope that helps!
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
MoondancerCommented:
Please update and finalize this question.  If you need Moderator assistance to split points or otherwise help with special handling, let us know via comment here or by posting a Zero point question with this question link in the Community Support topic area.
Thank you,
Moondancer - EE Moderator
0
 
pennnnCommented:
The user has a good record (accepted 37/38 answers), so maybe we should give him some time...
I was hoping to get feedback from him what he chose - there were three different working solutions.
In case he doesn't come back, we should probably split the points (although I think my solution is the best! :))
0
 
MoondancerCommented:
Excellent point, thank you.  Asker did log in 6/20/2002 and hopefully will update you here.
Moondancer - EE Moderator
0
 
anand_2000vCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
points to be split between pennnn , markgeer ,  and schwertner.
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

anand_2000v
EE Cleanup Volunteer
0
 
anand_2000vCommented:
Accepted. I am sorry that I did not notice the points here. All three answers are correct and therefore I had recomended a three wa split.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.