Home » RDBMS Server » Server Utilities » Using Sequence In Sql Loader
Using Sequence In Sql Loader [message #74559] Fri, 07 January 2005 00:33 Go to next message
ramesh
Messages: 123
Registered: August 2000
Senior Member
Hi,

I am trying to load data into a table using Sql Loader. I have data in 6 different control files. I have a primary key in the table, so i am using sequence for that. When i try to load data, the data from the first file is loaded properly, but for the subsequent files i am getting an error.

"SQL*Loader-459: error fetching numeric value for sequence on column (DATA_ID)
ORA-01502: index 'CAFCPGN.CD_PK_ID' or partition of such index is in unusable state"

My control file looks like this.
================================================
unrecoverable
LOAD DATA
INFILE 'graph_c7909_cpgndata.dat'
BADFILE 'graph_c7909_cpgndata.bad'
INTO TABLE CPGN_DATA APPEND
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
Data_id SEQUENCE(MAX),
Prod_Id,
Geog_Id,
Time_Id,
Meas_Id,
IData,
Cust_Fmt)
================================================

In my first control file i am using REPLACE and for the subsequent files APPEND. It is failing to append the data.

Kindly help me on this, i am not able to figure out the problem. Thanks in Advance.

Ramesh
Re: Using Sequence In Sql Loader [message #74560 is a reply to message #74559] Fri, 07 January 2005 00:45 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Is this a Direct load?
the index seems to be left in UNUSABLE state.
Check the status of index and try again.
And if you are loading Master / detail records using sequences, this is different case.
Re: Using Sequence In Sql Loader [message #74561 is a reply to message #74559] Fri, 07 January 2005 00:49 Go to previous messageGo to next message
how to get day in sql que
Messages: 4
Registered: January 2005
Junior Member
I am not able to understand ur problem exactly, anyway if u r using sequence in ur table and if it is a primary key, you can try like this.

column name sequence_name.nextval

columen name followed by sequence name.nextval

Regards
JAI
Re: Using Sequence In Sql Loader [message #74562 is a reply to message #74560] Fri, 07 January 2005 00:53 Go to previous messageGo to next message
ramesh
Messages: 123
Registered: August 2000
Senior Member
Yes, this is a direct load. This is not a master/detail records, but i have foreign key references to other tables.

Also i want to know will the same sequence used for loading all the 6 files. How does Oracle do this?
Re: Using Sequence In Sql Loader [message #74563 is a reply to message #74559] Fri, 07 January 2005 01:18 Go to previous messageGo to next message
ramesh
Messages: 123
Registered: August 2000
Senior Member
Hi Mahesh,

I just want to add one more thing to that, i am droping the table and creating that again before loading the data. Once the data is loaded, i am creating the index on the primary key along with other 3 fields which are not null fields. I have data for all these 4 fields.
Re: Using Sequence In Sql Loader [message #74567 is a reply to message #74563] Fri, 07 January 2005 04:50 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
check the status of this index (from user_indexes / dba_indexes.
THe index seems to be in usuable state or direct load state.

Direct load bypasses the RDBMS layer ( thats is why it is fast)
to do this it will disable the constraints before load
and later will try to enable the constraints.
If any a constraint is violated ( like in primary key, there is some duplicate record) the index will be left in a quasi state.

Please look thorughly into this.
Re: Using Sequence In Sql Loader [message #74568 is a reply to message #74562] Fri, 07 January 2005 04:56 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
the SEQUENCE parameter is handy.
But it may not work good when there are multiple sessions.
for complex operations, look into DATABASE Sequences as
JAI has stated.
< quoting docs >
Generating Sequence Numbers for Multiple Tables

Because a unique sequence number is generated for each logical input record, rather than for each table insert, the same sequence number can be used when inserting data into multiple tables. This is frequently useful.

Sometimes, however, you might want to generate different sequence numbers for each INTO TABLE clause. For example, your data format might define three logical records in every input record. In that case, you can use three INTO TABLE clauses, each of which inserts a different part of the record into the same table. When you use SEQUENCE(MAX), SQL*Loader will use the maximum from each table, which can lead to inconsistencies in sequence numbers.

To generate sequence numbers for these records, you must generate unique numbers for each of the three inserts. Use the number of table-inserts per record as the sequence increment and start the sequence numbers for each insert with successive numbers.
< /end quote docs >
Previous Topic: shell script parameters for sql loader!
Next Topic: Exporting table data, recreate database, and importing data
Goto Forum:
  


Current Time: Wed Jul 03 17:02:04 CDT 2024