Home » Developer & Programmer » Forms » Problem with inserting in the a trigger
Problem with inserting in the a trigger [message #631720] Mon, 19 January 2015 02:18 Go to next message
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 829 times)

[Updated on: Mon, 19 January 2015 02:21]

Report message to a moderator

Re: Problem with inserting in the a trigger [message #631745 is a reply to message #631720] Mon, 19 January 2015 07:06 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Oracle

ORA-01400: cannot insert NULL into (string)

Cause: An attempt was made to insert a NULL into the column "USER"."TABLE"."COLUMN".

For example, if you enter:

connect scott/tiger create table a (a1 number not null); insert into a values (null);

Oracle returns:

ORA-01400 cannot insert NULL into ("SCOTT"."A"."A1") : which means you cannot insert NULL into "SCOTT"."A"."A1".

Action: Retry the operation with a value other than NULL.
Re: Problem with inserting in the a trigger [message #631783 is a reply to message #631720] Mon, 19 January 2015 12:40 Go to previous message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
amjad_alahdal wrote on Mon, 19 January 2015 03:18

insert into BILL(Quantity)
values (new_val)
where good_name = good ;


This is not valid Oracle SQL.
Previous Topic: forms_radio button
Next Topic: LOV and Tab
Goto Forum:
  


Current Time: Tue Apr 23 16:02:14 CDT 2024