Solved

incorporate a sequence in control file

Posted on 2002-05-01
9
928 Views
Last Modified: 2008-03-10
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
0
Comment
Question by:surendranadh
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 47

Accepted Solution

by:
schwertner earned 30 total points
ID: 6985582
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
 
LVL 34

Expert Comment

by:Mark Geerlings
ID: 6985952
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
 
LVL 11

Assisted Solution

by:pennnn
pennnn earned 25 total points
ID: 6989033
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
 
LVL 1

Expert Comment

by:Moondancer
ID: 7096840
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 11

Expert Comment

by:pennnn
ID: 7097511
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
 
LVL 1

Expert Comment

by:Moondancer
ID: 7099112
Excellent point, thank you.  Asker did log in 6/20/2002 and hopefully will update you here.
Moondancer - EE Moderator
0
 
LVL 13

Expert Comment

by:anand_2000v
ID: 9204474
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
 
LVL 13

Expert Comment

by:anand_2000v
ID: 9257463
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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to recover a database from a user managed backup

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now