Solved

incorporate a sequence in control file

Posted on 2002-05-01
9
934 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 48

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 35

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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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
 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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 information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Suggested Courses

632 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