Oracle Forms Inserting Data from the form.

oracle United States
  • 17 years ago

    Hi,
    I am trying to use a form with a Button to make a new record, this sets the prodid feild to max(prodid) + 1 from the products table in the database. It then sets everything to blank.


    This works fine, but, when i try to save (another button) the record, which has:

    Code:
    insert into product
    values (:PRODUCT.PRODID, :PRODUCT.SUPPLIERID, :PRODUCT.DESCRIPTION, :PRODUCT.PRICE);
    COMMIT;

    As the PL/SQL For the WHEN-BUTTON-PRESSE trigger.


    When this button is pressed, the Runtime window says at the bottom:
    "FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-00001"


    If i take Database Error from the menu, it displays:

    Code:
    UPDATE PRODUCT SET PRODID=:1,SUPPLIERID=:2,DESCRIPTION=:3,PRICE=:4 WHERE ROWID=:5


    As being the SQL statement in error.
    This is (obviously) not right, since on the form Prodid is 3009, supplierid is 1005 etc.
    In SQL *Plus, if i select * from product where prodid = 1005, 3009, :1 I get various errrors (no rows selected for the first two and Bind variable "1" not declared for the last.


    Similarily, if i use the Update button, which has WHEN-BUTTON-PRESSED code of:

    Code:
    UPDATE product
    SET supplierid = :PRODUCT.SUPPLIERID,
    description = :PRODUCT.DESCRIPTION,
    price = :PRODUCT.PRICE
    WHERE
    prodid = :PRODUCT.PRODID;
    COMMIT;

    It gives an error (which i would expect since it doesnt exist yet).
    Specifically: FRM-40509: ORACLE error: unable to UPDATE record.
    The SQL statement in error is the same as previously mentioned in this.
    If i use Forms Runtime's own Add Item Button, along with my Update button this inserts without a problem, and, as expected the row appreas in SQL *Plus.


    I appologize if i have done something stupidly obvious but i am new to Oracle and would appreciate any help as to why i cant use my own Button and Save for the insersion of new data.


    Thank you.

  • 17 years ago

    Ok first of all, why are you using your own button for inserting data when oracle supplies one for you in its default menu?


    You are just making things hard for yourself.


    Also, you shouldn't need to do it that way because the data block is already linked to the data on your form and should update it when you change details anyway?

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter” - Eric Raymond