How to solve stock calculation Error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rohullah
    New Member
    • Mar 2010
    • 43

    How to solve stock calculation Error?

    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),to ns number);
    sql>table created

    create table companystock
    (Itemid number,ItemName varchar2(20),
    Itemtype varchar2(20),to ns number);
    sql>table created
    -----------------------------
    when i create primary key on companystock.it emid
    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.ite mid,0)=:company stock.itemid then
    update companystock set tons=tons+nvl(: orders.tons,0)
    where itemid=:orders. itemid;
    ELSIF nvl(:orders.ite mid,0)<>:compan ystock.itemid then
    insert into companystock(it emid,itemName,i temtype,tons)
    values
    (:orders.itemid ,:orders.:itemn ame,:orders.:it emtype,:orders. tons);
    commit_form;
    go_block('order s');
    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.it emid then
    it insert duplicate record into companystock.
    PLZ give me the best passible way to solve the problem.

    Looking forword.
    thank u in advance.
  • Jaydeep Paul
    New Member
    • Nov 2010
    • 3

    #2
    commit_form; is local for elsif block. In the if block it is doing the task but not getting commited.

    Comment

    Working...