Problem with inserting in the a trigger [message #631720] |
Mon, 19 January 2015 02:18 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/9996a32bf69a26d576c355127fae6a6d?s=64&d=mm&r=g) |
amjad_alahdal
Messages: 102 Registered: October 2013 Location: Saudi Arabia
|
Senior Member |
|
|
Hi guys, how are you doing?
I want to make a function or procedure that is dealing with two tables.
I have table 1 which is the storage table. I have two columns.
Good_name | Quantity
__________________________
The Bill table have multiple columns including
Good_name and Quantity.
Now, let's say if I have the following in the storage table;
Good_name | Quantity
Pencil 30
_______________________________
The bill table will be filled as the following :
Good_name | Quantity
Pencil 15
_________________________________________
in this case, after filling the 15 field. I want to do a subtraction in the storage table inside a trigger. I used the following code but it doesn't seem to work. The trigger is added in the POST_TEXT_ITEM
In the item quantity after filling :
DECLARE
result number ;
enter_val number := :BUYER_ENTERY_TABLE.QUANTITY ;
new_val number ;
good varchar2(500) := :BUYER_ENTERY_TABLE.GOOD_NAME ;
Begin
select Quantity into Result
from BILL
where GOOD_NAME =good ;
new_val := Result - enter_val ;
If (new_val > 0)
THEN
insert into BILL(Quantity)
values (new_val)
where good_name = good ;
:BUYER_ENTERY_TABLE.QUANTITY := enter_val ;
SETSTORAGE(enter_val,good) ;
Elsif (new_val=0)
Then
insert into BILL(Quantity)
values (new_val)
where good_name = good ;
SETSTORAGE(enter_val,good) ;
ELSE
message('You have Entered more than in the stock ');message(' ');
:BUYER_ENTERY_TABLE.QUANTITY := 0 ;
END IF ;
END ;
I am getting errors in the where condition. Even if I try to delete the where condition. The form doesn't work and insert anything. I know I have some problems, I need your help.
Any decisions
-
Attachment: Error.png
(Size: 1.47KB, Downloaded 997 times)
[Updated on: Mon, 19 January 2015 02:21] Report message to a moderator
|
|
|
|
|