?
Solved

SQL Loader, inserting a nextval from a sequence.

Posted on 2004-10-15
3
Medium Priority
?
10,269 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
[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
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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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ā€¦
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

762 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