Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

incorporate a sequence in control file

Posted on 2002-05-01
9
Medium Priority
?
935 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 120 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 100 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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…

704 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