Solved

SQL Loader, inserting a nextval from a sequence.

Posted on 2004-10-15
3
9,694 Views
Last Modified: 2008-01-09
I have several table in oracle which I insert data into, and I want to user sql loader, the basic format of the table are:

member_id;
client_id constant 123456;
name;
email;

The member_id is a unique member number which is generated from a sequence which I have created:
 CREATE SEQUENCE SEQ_MEMBER_ID_TMP
  START WITH 468967645
  MAXVALUE 999999999999999999999999999
  MINVALUE 84761410
  NOCYCLE
  CACHE 20
  NOORDER;

which was created OK.  

I just need a control file to insert a list of email and names, and with inserting the member_id and also updating the sequence so that next time it is run the start with value is different as I'm not sure if this will automatically change.  

Thanks,

Manoj
0
Comment
Question by:mmatharu
  • 2
3 Comments
 
LVL 11

Expert Comment

by:cjjclifford
ID: 12321136
not sure how to get sqlloader to insert values from a sequence - perhaps use sqlloader to load into a staging area (i.e. a seperate table), and then fire a SQL statement to insert into the destination table the data from the staging area, along with SEQ_MEMBER_ID_TMP.NEXTVAL.

Or, you could look at defining an INSERT trigger on the destination table

create trigger seqinserttrig ON destination BEFORE INSERT for each row
begin
    select SEQ_MEMBER_ID_TMP.nextval FROM dual INTO :NEW.member_id;
end;
/

Not sure how fast this would be - probably using a staging table (created in a tablespace that has NOLOGGING) is the better way....
0
 
LVL 23

Accepted Solution

by:
seazodiac earned 250 total points
ID: 12321169
in your control file:




load data
into table <table_name>
(
member_id "SEQ_MEMBER_ID_TMP.nextval";
client_id constant 123456;
.....
...
)

0
 
LVL 11

Expert Comment

by:cjjclifford
ID: 12321293
there you go - much simpler!
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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

757 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

20 Experts available now in Live!

Get 1:1 Help Now