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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to Update a UNIQUE field ?

Re: How to Update a UNIQUE field ?

From: Galen Boyer <galenboyer_at_hotpop.com>
Date: 16 Apr 2002 21:33:04 -0500
Message-ID: <uofgizy1d.fsf@rcn.com>


On Tue, 16 Apr 2002, rchin_at_panix.com wrote:

> MY_TAB gets loaded daily, one UNIQUE-indexed field COL_UNIQ does NOT
> get values in the loading.... I need to populate this field with
> unique values....
>
> How can I UPDATE this field with (where is null) values (from a
> SEQUENCE) ?
Okay, it doesn't seem that you are creating your primary key row on the load, and you want to do it after the fact?

You also just need it to be unique?

        SQL> create table t1 (fld1 number);

        Table created.

        SQL> insert into t1 select rownum from merchandise_hierarchy_tbl where rownum < 5;

        4 rows created.

        SQL> select * from t1;

              FLD1
        ----------
                 1
                 2
                 3
                 4

        SQL> DECLARE
             x number;
             BEGIN
             select max(fld1) into x from t1;
             update t1 set fld1 = rownum + x;
             END;
        /

        PL/SQL procedure successfully completed.

        SQL> select * from t1;

              FLD1
        ----------
                 5
                 6
                 7
                 8

You should be able to do something similar for your field?

-- 
Galen deForest Boyer
Sweet dreams and flying machines in pieces on the ground.
Received on Tue Apr 16 2002 - 21:33:04 CDT

Original text of this message

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