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: PL/SQL questions

Re: PL/SQL questions

From: Vladimir M. Zakharychev <bob_at_dpsp-yes.com>
Date: Tue, 30 Apr 2002 11:27:11 +0400
Message-ID: <aalke0$t9d$1@babylon.agtel.net>

I guess this is BEFORE INSERT trigger. Alter it to AFTER INSERT and constraints should pass because inserted data is already visible within the transaction. Make sure that the trigger is FOR EACH ROW either.

--
Vladimir Zakharychev (bob@dpsp-yes.com)                http://www.dpsp-yes.com
Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications.
All opinions are mine and do not necessarily go in line with those of my employer.


"piyush rampuria" <utickle_at_yahoo.com> wrote in message
news:b999e95e.0204290909.626f2f47_at_posting.google.com...

> I have two tables
>
> Enroll (StudentID, courseId, paymentoption)
> Bills (bill_no, studentid, courseid, coursefees, interest, total)
>
> the primary key of enroll (studentid + courseId) is the foreign key of
> bills.
> the primary key of bills is bill_no which is a sequence
>
> now the problem.
>
> I have write a program which will do the following
>
> When one inserts an enroll record, the program should insert a bill
> for that student itself. and it should be complicated enough to tackle
> the payment option thing, as in if the paymentoption is cash then give
> two percent discount based on that calculate totals.
> otherwise not.
>
> Notice that the coursefees attribute of bills should be derived from
> the table courses(courseid, coursefees)
>
> In plsql i tried to write a trigger for enroll dept which satisfies
> certain conditions. The problem is that if a tuple passes the
> constraints in the trigger then... i get an error that says that
> violates the foreign key constrain of bills table. and to think of it
> it makes sense, because I called the procedure insert bill from the
> trigger itself....so even before the enroll record is inserted in
> enroll table it tries to insert that record in bills table and that
> gives me a foreign key violation. does anyone know how to come around
> this problem???
>
> Thanks in advance
> piyush
>
>
> may be i m trying to do too much....
Received on Tue Apr 30 2002 - 02:27:11 CDT

Original text of this message

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