This discussion is archived
4 Replies Latest reply: Dec 3, 2012 12:45 AM by 963899 RSS

Add an update button

963899 Newbie
Currently Being Moderated
Hello everyone!

I am using Oracle Forms 6i and here is my problemm..

I am trying to add a button in my forms that will update records in my table.
For example I have one datacolumn "TYPE_OF...", in my forms I made an ListItem for this column where I choose the type.
I made a recordGroup to automaticaly populate this item and everything works just fine.

Now when I press this button of mine (I named it "Change") I want to update my record and save it with the different type that I choose after saving the record first and the previuos record with the "old" type must be erased (not to have both records afterwards).

I started like this:

1. Made an alert (named "SPR") that will ask me when I press the button if I am sure that I want to change that record.
2. Alert have two buttons "Yes" and "No"
3. When I click on "Yes" my record is updated else nothing happens

Here is the CODE that I wrote in WHEN-BUTTON-PRESSED trigger (It doesn't work, normally, because I am quite new in PL/SQL programming):
DECLARE
     a NUMBER;
BEGIN
     a := SHOW_ALERT('SPR');
         IF a = Alert_Button1 THEN
          UPDATE My_Table (in my case name of the table is DOKUMENTI_GLAVA_UV - it's in Slovenian and it means Documents_Head)
          SET TYPE_OF.. (my case VRSTE_TEMELJNICE - means type of journal) = :D.TYPE_OF..; (my case - D is name of the block)
         ELSE
              RAISE FORM_TRIGGER_FAILURE;                  
  END IF;            
END;
It gives me error and says that My_table must be declared.

All I want is the CODE for my trigger and some advice if I make something wrong or I am trying to do something that it can not be done that way.

Thank you!
  • 1. Re: Add an update button
    MLBrown Journeyer
    Currently Being Moderated
    If you are getting a "DOKUMENTI_GLAVA_UV must be declared" error, then it sounds like a grant issue. Are you executing the form as a different user from the person that owns the table? If you are, does that person have access to that object? Also, if you don't prepend the SCHEMA name in front of the objects, does a synonym exist that will allow the user executing the form the ability to see the object.

    If the person does not have rights to the object do a:
    grant select, update to DOKUMENTI_GLAVA_UV to ...
    where ... is the user, role, PUBLIC. You could Google that to find more info.

    As far as what you are doing is possible. I assume that D block is a non-database block which is why you are doing the DML? If D is a database block, that references the DOKUMENTI_GLAVA_UV table, then you should not do the DML. You should just let forms update the record for you.
  • 2. Re: Add an update button
    963899 Newbie
    Currently Being Moderated
    First of all, Thank you!

    I don't have anymore the problem with "DOKUMENTI_GLAVA_UV must be declared", I saw that I have to be signed in one another application that uses this form, so that is not an issue anymore.

    Now I made one another block that is not database block, add in that block some display items that will copy my type of "VRSTE_TEMELJNICE" and beneath that item, I add ListItem on which I defined RecordGroup where I can choose my new type. I also add two buttons on this block where one is "Cancel" and the other is "OK" which means if I press on "OK" I want to change the type.

    Just to answer on your question the D block is a database block but I have to do this because the item "VRSTE_TEMELJNICE" is unupdatable (update allowed is set to NO) and it has to be that way, so I can not just let forms to update the record.

    So.. let's return on my issue. If I press on "OK" button my alert shows up and if I press "Yes" my record is updated.

    The name of my displayItem is "IZVT", of listItem is "NAVT". I hope you can get the picture, if not, just tell me what is unclear and I'll try to explain.

    So, I still need the CODE for my trigger on the "OK" button.
  • 3. Re: Add an update button
    MLBrown Journeyer
    Currently Being Moderated
    What kind of errors are you receiving now if the "must be declared" error is resolved?

    >
    Just to answer on your question the D block is a database block but I have to do this because the item "VRSTE_TEMELJNICE" is unupdatable (update allowed is set to NO) and it has to be that way, so I can not just let forms to update the record.
    >

    Even though you have the "Update Allowed" item property set to "No" you can still update the item with trigger logic. The user won't be able to when they are running the form but you can which would allow forms to handle the update to the database which is always better than using DML. Try changing your CODE.WHEN-BUTTON-PRESSED trigger logic to:
    DECLARE
      a NUMBER;
    BEGIN
      a := SHOW_ALERT('SPR');
      IF a = Alert_Button1 THEN
        :D.VRSTE_TEMELJNICE := :D.TYPE_OF...;  -- Whatever the real names of the blocks and items are
      ELSE
        RAISE FORM_TRIGGER_FAILURE;                  
      END IF;            
    END;
  • 4. Re: Add an update button
    963899 Newbie
    Currently Being Moderated
    Thank you!

    Everything works fine. :)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points