Hello
I have to two tables as following
-----------------------------
create table orders
(orderid number primary key,
orderdate date,Ename varcarh2(20),
ItemID number,ItemName varchar2(20),
Itemtype varchar2(20),tons number);
sql>table created
create table companystock
(Itemid number,ItemName varchar2(20),
Itemtype varchar2(20),tons number);
sql>table created
-----------------------------
when i create primary key on companystock.itemid
reference it to orders.itemid then
in the form6i I create abutton by the name of Save Record
and i do the following code for the button
WHEN-BUTTON-PRESS trigger
----------------------------
begin
if nvl(:orders.itemid,0)=:companystock.itemid then
update companystock set tons=tons+nvl(:orders.tons,0)
where itemid=:orders.itemid;
ELSIF nvl(:orders.itemid,0)<>:companystock.itemid then
insert into companystock(itemid,itemName,itemtype,tons)
values
(:orders.itemid,:orders.:itemname,:orders.:itemtyp e,:orders.tons);
commit_form;
go_block('orders');
execute_query;
end if;
exception when others then
message('Record Not Saved Successfull');
end;
--------------------------------
it insert record but it not update the record;
if i remove the primary key from companystock.itemid then
it insert duplicate record into companystock.
PLZ give me the best passible way to solve the problem.
Looking forword.
thank u in advance.