Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Other Programming Languages (http://www.programmingforums.org/forum38.html)
-   -   Before Insert Trigger Problem (http://www.programmingforums.org/showthread.php?t=15614)

namsu Apr 14th, 2008 1:43 PM

Before Insert Trigger Problem
 
I am making a trigger to check the whether the branch number is equal to 1 or 2, if the value is 1, it will select a table
if the value is 2, it will select a table (different to option 1).

I think the trigger should check whether the branchNo is 1, to do this i would like the trigger to check the foreign key of the order table which is called customerNo, it will then look at the customers branch using the foriegn key in the customer table which is the branchNo.

I think I am having trouble with PL-SQL syntax or maybe this is another problem that I do not know of, please can you help me.
Here is some code:
:


order_g.customerNo = customer_g.customerNo
and customer_g.branchNo = branch.branchNo
and location = 'Greenwich';


Here is some code of the whole trigger:

:


create or replace trigger os_trigger
before insert on order_g
for each row
declare
order_g.customerNo = customer_g.customerNo
and customer_g.branchNo = branch.branchNo
and location = 'Greenwich';
begin
if (:new.branchNo = 1)
then
select seq_order_g_id into :new.orderNo from dual;
else
select seq_order_e_id into :new.orderNo from dual;
end if;
end;
/


If someone can help me out that has some knowledge in this area, that would be nice. I have been searching the net, using examples and such, but I still cannot overcome the problem.


All times are GMT -5. The time now is 4:16 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC