From oracle-l-bounce@freelists.org Wed May 18 12:49:15 2005 Return-Path: Received: from air891.startdedicated.com (root@localhost) by orafaq.com (8.12.10/8.12.10) with ESMTP id j4IHnFaf000946 for ; Wed, 18 May 2005 12:49:15 -0500 X-ClientAddr: 206.53.239.180 Received: from turing.freelists.org (freelists-180.iquest.net [206.53.239.180]) by air891.startdedicated.com (8.12.10/8.12.10) with ESMTP id j4IHnD4Z000938 for ; Wed, 18 May 2005 12:49:15 -0500 Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 49961195188; Wed, 18 May 2005 11:46:22 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 02407-01; Wed, 18 May 2005 11:46:22 -0500 (EST) Received: from turing (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id B5B5F194DC3; Wed, 18 May 2005 11:46:21 -0500 (EST) Priority: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 content-class: urn:content-classes:message MIME-Version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: RE: TRIGGERS Date: Wed, 18 May 2005 10:43:53 -0600 Message-ID: <17CAB0BF27BCFC47B0E4554A0E2F962B4396FD@fiji.arraybp.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: TRIGGERS Thread-Index: AcVbx2Je2GsVXI3tR+KGS5DeaBztdQAAROfg From: "Reidy, Ron" To: , X-OriginalArrivalTime: 18 May 2005 16:43:52.0934 (UTC) FILETIME=[C65A9860:01C55BC8] X-archive-position: 19871 X-ecartis-version: Ecartis v1.0.0 Sender: oracle-l-bounce@freelists.org Errors-To: oracle-l-bounce@freelists.org X-original-sender: Ron.Reidy@arraybiopharma.com Precedence: normal Reply-To: Ron.Reidy@arraybiopharma.com X-list: oracle-l X-Virus-Scanned: by amavisd-new-20030616-p9 (Debian) at avenirtech.net X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on air891.startdedicated.com X-Spam-Status: No, hits=0.4 required=5.0 tests=AWL,LINES_OF_YELLING, LINES_OF_YELLING_2,SUBJ_ALL_CAPS autolearn=no version=2.63 JK, Have you read anything about PL/SQL generally and triggers specifically? Someone earlier mentioned you may have a design issue here, and I would = agree with that. You might consider rethinking what you are doing. ----------------- Ron Reidy Lead DBA Array BioPharma, Inc. -----Original Message----- From: oracle-l-bounce@freelists.org [mailto:oracle-l-bounce@freelists.org]On Behalf Of Kean Jacinta Sent: Wednesday, May 18, 2005 10:34 AM To: oracle-l@freelists.org Subject: Re: TRIGGERS HI, here is what i have written in trigger body, i am really stuck here. help me up , it;s still not working . System still complain about the unique key error. **:( DECLARE REFCOUNT NUMBER; DUP_VAL_ON_INDEX EXCEPTION; TEMP NUMBER; =20 BEGIN IF INSERTING THEN =20 LOOP =20 SELECT COUNT(*) INTO REFCOUNT FROM myclass WHERE :NEW.id =3D id; =20 IF REFCOUNT > 0 THEN --RECORD EXISTED IN DATABASE SELECT myclass_seq.NEXTVAL INTO TEMP FROM DUAL; END IF; =20 =20 END LOOP; =20 =20 IF :NEW.ID IS NULL THEN =20 =20 SELECT myclass_SEQ.NEXTVAL=20 INTO :NEW.ID=20 FROM DUAL; END IF; =20 END IF; --MAIN IF END; Note : have no idea how to use the exception handler=20 JKean --- david wendelken wrote: > If you really want to handle that, you have three > choices: >=20 > 1) Live with it. If you have a program that > assigns the id values for you, it should be getting > its next value from the sequence also. If you do > that, this just isn't a problem in real life. If > you aren't willing to ALWAYS get the next id value > from a sequence, you probably shouldn't be using a > sequence at all. >=20 > 2) Relatively simple, partial solution. Use a > pre-statement trigger on insert, have it grab the > next sequence value and verify that the record for > that sequence number is not already in the table.=20 > If it is, get the next sequence value until you find > an empty one. Assume that all the ones after that > are ok from then on. Ignore the fact taht you throw > away a sequence number each time you do a statement. > Remember, I said *partial* solution. >=20 > 3) Read up on mutating table errors and autonomous > transactions. This will take you awhile to read and > experiment with. We have time to help with specific > problems, but not to write it for you. > Ask again after you've read that material and are > are stuck. >=20 >=20 >=20 > -----Original Message----- > From: Kean Jacinta > Sent: May 18, 2005 8:02 AM > To: david wendelken > Subject: Re: TRIGGERS >=20 > david, >=20 > :P oh i see . I am so blur. My concern, >=20 > ID =20 > --- > 1 <-- autogenerated > 2 <-- autogenerated > 3 <-- autogenerated > 4 <-- manually created > 5 <-- manually created=20 >=20 > My current sequence stay at : 3 , if i issued an > autotgenerated insert again it will surely prompt > unique id alrdy existed... or some sort of database > error. How can then trigger being smart enough to > silently generate autoid 6 without raising error ? >=20 > I am very close to my objectives alrdy :P >=20 > Thank in advance > Jkean=20 >=20 =09 __________________________________=20 Yahoo! Mail Mobile=20 Take Yahoo! Mail with you! Check email on your mobile phone.=20 http://mobile.yahoo.com/learn/mail=20 -- http://www.freelists.org/webpage/oracle-l This electronic message transmission is a PRIVATE communication which = contains information which may be confidential or privileged. The information is = intended=20 to be for the use of the individual or entity named above. If you are = not the=20 intended recipient, please be aware that any disclosure, copying, = distribution=20 or use of the contents of this information is prohibited. Please notify = the sender of the delivery error by replying to this message, or notify us = by telephone (877-633-2436, ext. 0), and then delete it from your system. -- http://www.freelists.org/webpage/oracle-l