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: Why Oracle don't have AUTO_INCREMENT as in MySQL

Re: Why Oracle don't have AUTO_INCREMENT as in MySQL

From: DA Morgan <damorgan_at_psoug.org>
Date: Mon, 23 Apr 2007 08:10:17 -0700
Message-ID: <1177341017.291504@bubbleator.drizzle.com>


hasta_l3_at_hotmail.com wrote:

> On 22 avr, 20:07, DA Morgan <damor..._at_psoug.org> wrote:
>> hasta..._at_hotmail.com wrote:

>>> What people would like is to *supplement* sequences
>>> with a declarative way to telloracle: Please provide
>>> a unique value for this primary key if none specified.
>>> Something like DB2, which - as I get it - has both
>>> SEQUENCEs and IDENTITY columns...
>> I can understand the allure of such but laziness being
>> what it is I would expect most developers to be lazy and
>> the quality of applications to suffer.
>> --
> 
> Quite to the contrary, Daniel.  The less code you write,
> the most solid an application is...

Based on that statement then I would assume that

BEGIN
   FOR r IN (SELECT * FROM parent)
   LOOP

is more efficient than:

DECLARE TYPE myarray IS TABLE OF parent%ROWTYPE; l_data myarray;

CURSOR r IS
SELECT part_num, part_name
FROM parent;

BEGIN
   OPEN r;
   LOOP
     FETCH r BULK COLLECT INTO l_data LIMIT 1000;

     FOR j IN 1 .. l_data.COUNT
     LOOP
       l_data(1).part_num := l_data(1).part_num * 1;
     END LOOP;

     FORALL i IN 1..l_data.COUNT
     INSERT INTO child VALUES l_data(i);

     EXIT WHEN r%NOTFOUND;

   END LOOP;
   COMMIT;
   CLOSE r;
END fast_way;
/

I can get you a couple of dozen other similar examples if you'd like.

The truth is that the less code you write the less is written. It has nothing whatsoever to do with the quality, performance, or scalability.

You might wish to reconsider.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Mon Apr 23 2007 - 10:10:17 CDT

Original text of this message

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