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: Before insert trigger code

Re: Before insert trigger code

From: Rajagopal Venkataramany <rajagopalvr_at_excite.com>
Date: Tue, 28 Nov 2000 15:05:44 -0800 (PST)
Message-Id: <10694.123135@fatcity.com>


Hi,

   You will run into "mutating error" if u try to implement it it    before insert trigger.

   You need to store the primary key value of the row that is    being inserted into a temp_table using a row level trigger.

   Then in the statement level trigger read the row that was    inserted using the key value from the temp_table. Do the    validation. If the validation detects "overlaps" then raise    a exception which would also rollback the row that was inserted    in the temp_table. if the validation did not detect any "overlaps"    then delete the row that u inserted into the temp_table in the    statement level trigger itself.

   Hope this helps...

Regards
Rajagopal Venkataramany  

On Mon, 27 Nov 2000 23:20:20 -0800, ORACLE-L_at_fatcity.com wrote:

> Dear all,
>
> I have a table by name image_master whose structure is as below:
>
> IMAGE_NAME NOT NULL
> VARCHAR2(60)
> TYPE NOT
NULL
> CHAR(1)
> START_DT NOT NULL
> VARCHAR2(8)
> EXPIRY_DT
> VARCHAR2(8)
> IMAGE_DESC
> VARCHAR2(600)
> CREATE_DT
> VARCHAR2(8)
> MODIFY_DT
> VARCHAR2(8)
>
> The dates are entered in the form 'yyyymmdd'. All the dates have been
> assigned the datatype as varchar2(8) instead of date for a specific
reason.
> I would like to create a before insert trigger on the table so that the
> user cannot insert a record if the start_dt and expiry_dt overlap the
> existing start_dt and expiry_dt in the existing records. For example,
if
> there is a record whose start_dt is 20001126 and end_dt is 20001128 then
> the user is not allowed to have start_dt and end_dt between 26th and 28th
> November, 2000 (both dates inclusive). His start_dt and end_dt can be
any
> dates apart from 26th, 27th and 28th November. How do I implement this
> using SQL or PL/SQL? Is there any other way out apart from creating a
> before insert trigger? I hope I am clear. Any help in this regard will
> be highly appreciated.
>
> TIA and regards,
>
> Ranganath
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author:
> INET: RanganathK_at_lgcommerznow.com
>
> 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).

Regards
Rajagopal Venkataramany



Tired of slow Internet? Get @Home Broadband Internet Received on Tue Nov 28 2000 - 17:05:44 CST

Original text of this message

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