Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: sequences and loading from sqlldr

Re: sequences and loading from sqlldr

From: <bdw_at_affinia.net>
Date: 2000/06/30
Message-ID: <8jj8ne$16l$1@nnrp1.deja.com>

I haven't had time to try this but it looks pretty cool ... intuitively I say to myself 'of course there's a way'.

Anyway as an aside this probably wouldn't work with a direct path load, which is important for fast data loads.

As such in the application I am working on now we forget the sequence altogether and select max(value) out of the table before we format the loader file. That works ..... and is old school. Kind of like sybase. It will work with parallel loads also.

-bdw

In article <395297EF.3479E4C9_at_hotmail.com>,   kskasi_at_hotmail.com wrote:
> Hi guys
>
> I think you are missing something here. We can actualluy use Oracle
 sequence
> in SQL loader.
> Check the following examples
> Example-I:
> =========
>
> In the first example, all of the fields are located in the datafile
> based on position, which makes this easier. Another example below
 covers
> data that
> is comma delimited.
>
> We want to load the data into the following table:
>
> SQL> CREATE TABLE load_db_seq_positional
> 2 (seq_number NUMBER,
> 3 data1 NUMBER,
> 4 data2 CHAR(15) );
>
> We will use the following sequence:
>
> SQL> CREATE SEQUENCE db_seq
> 2 START WITH 1
> 3 INCREMENT BY 1;
>
> The control file would look like:
>
> LOAD DATA
> INFILE *
> INTO TABLE load_db_seq_positional
> (seq_number "db_seq.nextval"
> data1 POSITION(1:5),
> data2 POSITION(6:15),
> )
> BEGINDATA
> 11111AAAAAAAAAA
> 22222BBBBBBBBBB
>
> After we run SQL*Loader, our table data looks like:
>
> SQL> SELECT * FROM load_db_seq_positional;
>
> SEQ_NUMBER DATA1 DATA2
> ---------- ---------- ---------------
> 1 11111 AAAAAAAAAA
> 2 22222 BBBBBBBBBB
>
> Example-II:
> ==========
>
> In this example, the data fields are comma delimited. The key here is
> that since fields are delimited, SQL*Loader will expect to find
 values for
> the field SEQ_NUMBER in the data file. Since such entries do not
 exist,
> what we must do is to put the SEQ_NUMBER field as the last field in
 the
> control file, and then use the TRAILING NULLCOLS clause to indicate to
> Loader
> that on some lines (in this case all), there may be "trailing
 columns" which
>
> are null, or non-existent.
>
> Here is the similar create table statetement, we will use the same
> sequence:
>
> SQL> CREATE TABLE load_db_seq_delimited
> 2 (seq_number NUMBER,
> 3 data1 NUMBER,
> 4 data2 CHAR(15));
>
> The control file would look like:
>
> LOAD DATA
> INFILE *
> INTO TABLE load_db_seq_delimited
> FIELDS TERMINATED BY ","
> TRAILING NULLCOLS
> (data1,
> data2,
> seq_number "db_seq.nextval"
> )
> BEGINDATA
> 11111,AAAAAAAAAA
> 22222,BBBBBBBBBB
>
> cheers...kasi
>
> ddf_dba_at_my-deja.com wrote:
>
> > In article <8itl83$ffn$1_at_nnrp1.deja.com>,
> > yong321_at_yahoo.com wrote:
> > > In article <8itimj$d6v$1_at_nnrp1.deja.com>,
> > > ddf_dba_at_my-deja.com wrote:
> > > > In article <8itf83$aa0$1_at_nnrp1.deja.com>,
> > > > orauser_at_my-deja.com wrote:
> > > > > I want to load data from a text file, into a table
> > > > > that contains a sequence.
> > > > >
> > > > > I am using sqlldr to load this data into a temp table
> > > > > and then doing an insert from this temp table into
> > > > > my database, invoking the sequence in the process.
> > > > >
> > > > > Is this necessary? Any better way to do this?
> > > > >
> > > > > Sent via Deja.com http://www.deja.com/
> > > > > Before you buy.
> > > > >
> > > >
> > > > If you are using the sequence for other processing other than
 bulk
 loads
> > > > there really is no other way. SQL*Loader provides the SEQUENCE
 syntax
> > > > but that is independent of any sequence built in the instance

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Fri Jun 30 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US