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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: why this code does not work in sqlplus?

Re: why this code does not work in sqlplus?

From: William Beilstein <BeilstWH_at_obg.com>
Date: Mon, 22 May 2000 12:22:08 -0400
Message-Id: <10505.106245@fatcity.com>


sequences are used to generate a UNIQUE value that is normally used for = primary keys. You may NOT use a function to set the value. It starts at a = specific point and increments by the value you give it. If you want a = value that is one greater then the max of all the current values, Lock the = table, find the max value, increment the value by one, store the value in = the row and commit, which will unlock the table.

>>> "Guang Mei" <zlmei_at_hotmail.com> 05/22/00 11:58AM >>>
Hi:

I am trying to create some oracle sequence based on the current max ID=20 value. Does any one know why it does not work in sqlplus? I got the=20 following error:

MAX(PROMOTIONID)


           69819
       START WITH :maxpromotionid +1
                  *

ERROR at line 3:
ORA-01722: invalid number

Here is the script:



variable maxpromotionid NUMBER;

select max(promotionID)
into :maxpromotionid
from hpxpromotion;

CREATE SEQUENCE HPXSEQ_Promotion

       INCREMENT BY 1
       START WITH :maxpromotionid +1
       MAXVALUE   999999999
       MINVALUE   1
       NOCYCLE
       NOCACHE;
----------------------

If you reply, please send me a copy to zlmei_at_hotmail.com=20

Thanks.

Guang



Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com=20=

--=20
Author: Guang Mei
  INET: zlmei_at_hotmail.com=20

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Mon May 22 2000 - 11:22:08 CDT

Original text of this message

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