home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!hayes!fgreene
- From: fgreene@hayes.com
- Newsgroups: comp.databases.oracle
- Subject: Re: SQL*Loader REALLY unique sequences
- Message-ID: <6536.2b2c54be@hayes.com>
- Date: 14 Dec 92 09:32:46 EDT
- References: <1gacpnINNbjl@fmsrl5.srl.ford.com>
- Organization: Hayes Microcomputer Products, Norcross, GA
- Lines: 61
-
- In article <1gacpnINNbjl@fmsrl5.srl.ford.com>, hugh@slee01.srl.ford.com (Hugh Fader) writes:
- > I am developing a system which needs to append ASCII data into a table
- > and generate a unique identifier for each new row. SQL*Loader has a
- > SEQUENCE function which will generate unique sequence number, but the
- > numbers will only be unique for a given SQL*Loader session, not for
- > the destination table.
- >
- > Can anybody offer a way to get SQL*Loader to give me a sequence number
- > which is unique for the entire table?
- >
- > Thanks in advance.
- >
- > --
- > Hugh Fader
- > Ford Research Laboratory
- > hugh@slee01.srl.ford.com
- >
- You are on the right track with SEQUENCE, but you need to add the MAX
- option. Assume a target table TEST with columns SEQVAR NUMBER, VAR1 TEXT,
- and VAR2 TEXT with values of
-
- SEQVAR VAR1 VAR2
- ------ ---- ----
- 1 AAA ZZZ
- 2 BBB YYY
- 3 CCC XXX
-
- and an input ASCII table TEST.DAT with contents of
-
- ddd,www
- eee,vvv
-
- to load these variables with correct sequence numbers, use
-
- load data
- infile test.dat
- into table test
- append
- fields terminated by ',' optionally enclosed by '"'
- (SEQVAR SEQUENCE(MAX, 1), -- ***** here is the sequence needed ***
- var1,
- var2)
-
- The SEQUENCE(MAX, 1) function attached to SEQVAR variable tells Oracle to scan
- the existing table for the maximum value and then increment all successive
- entries by 1. Check pg 7-19 of the Utilities manual.
-
- The basic function works great. I have never tested to see what happens if you
- have a rejected record. That is, does Oracle assign a number and then reject
- the record leaving a gap, or does it reject the record first leaving some
- records without sequence numbers. My guess is that it is position dependent.
-
- ---------------------------------------------------------------------------
- | Frank Greene | ////// ////// |
- | DELPHI SYSTEMS, Inc. | //// //// |
- | Telephone [615] 458-6032 | //// //// ////// |
- | 324 Ootsima Way | //// //// //// |
- | Loudon, TN 37774 | ////// ////// ////// |
- ----------------------------------------------------------------------------
- | Of course, any opinions or suggestions are strictly my own |
- ----------------------------------------------------------------------------
-