Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Loader, inserting a nextval from a sequence.

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

618 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