Link to home
Start Free TrialLog in
Avatar of mansi
mansi

asked on

Updating Base table from devel.2000 forms 4.5

I  have  a  table named  deposit_master in Oracle SQL*Plus 3.2 data base . There are many columns in this table. Two of them are account_no &  deposit_status.
      Initially the deposit_status of an account no. is ‘working’. When the deposit is matured  the status of that particular account_no has to be changed to ‘matured’.
      Now with stored procedures run in the SQL3.2  database(back end level)  this is possible &  the field  deposit_status does get updated. But  when I run the same stored proc.From developer 2000(Forms 4.5) it is not getting updated.
      I tried with update_allowed (block) property & update_allowed(item)
keeping TRUE. But no success. I used  update_allowed property in trigger  WHEN-NEW-BLOCK-INSTANCE.
      Can above mentioned properties or update_changed_columns property be used ? If yes how & where to use them( in new-form-instance or new-item-instance trigger)? How to grant user the permission to UPDATE a row in database from DEVELOPER 2000(Forms 4.5).
      I am using oracle on my home PC.So please guide me.

Avatar of Mark Geerlings
Mark Geerlings
Flag of United States of America image

How are you calling the stored procedure from Forms?  It should be in a commit-time trigger (pre- or post-insert, pre- or post-update or possibly pre- or post-delete).

You will definitely need to have "Update allowed" = TRUE for the block, assuming that you want the stored procedure in the database to be fired when you update a row in the form.

You do not need to (and you cannot) grant update permission to a form or block.  Select and update permission on the table must be granted to the Oracle user who will run the form.
Avatar of mansi
mansi

ASKER

Dear Markgeer,
            Thanks a lot for offering me help.
      I have a stored procedure interest_cal at back-end.In my form (whose base     table is deposit_master) I have put a push-button 'Calculate'. and for that     push_button, I have put 'When-button-pressed' trigger. In that trigger I call       the stored procedure interest_cal. It gets executed without any error. It shows
    the interst calculated by the procedure in Interst field on the form.(Interest      field is not a base table item). But it doesn't update the deposit_status for     that particular account_no in the database. Same stored procedure updates the     status from 'working' to 'matured' when run from database.
      Earlier I had tried to assign "UPDATE ALLOWED"= TRUE for block in         when-new-block-instance trigger defined at block_level. Then I tried same under     PRE-UPDATE trigger at the block level, still it doesn't work.
      To ensure the updation of database from developer2000 , how many of the     following properties should be set explicitely?
      1) UPDATE_ALLOWED  in set_block_property       
      2) UPDATE_CHANGED_COLUMNS in set_block_property
      3) UPDATEABLE  in set_item_property
      4) UPDATE_PERMISSION in set_item_property
          Under which trigger ( when-new-form-instance or when-new-block-instance
          or pre-update) they should be set and what level ( form or block if the           trigger is pre_update or so).

mansi

r u updating the deposit_status of an account no in the stored procedure when u r calling from forms via update statement ? if not then u need to set the value in the deposit_status field explicitly to 'matured' in the forms after u finish executing the stored procedure and then commit so that the data in the base table block gets saved.

r u getting any error when u commit?






Avatar of mansi

ASKER

Dear savvyg,
            Thanks a lot for offering me help.
      I am updating the deposit_status of an account_no in the stored         procedure itself. But as I have stated in the question, it does
      not get updated. So I tried to change it explicitly in the forms after       executing the stored procedure. Still no change.If I put commit after       explicitly trying to update the status in the forms, it shows error that         'record has already been inserted'.(may be because the same account_no         already exists in the table & it has not been updated in the procedure         or explicit update in the forms.).

Do not change the block or item properties in triggers.  Just set them appropriately in the property sheets for those items in Forms Designer.  The properties you need are:
1) block property: UPDATE_ALLOWED    
2) item_property: UPDATEABLE (for items that should be updated in the form)

Does your stored procedure calculate an interest amount or update the deposit_status, or both?

What kind of change or activity in the form should cause your stored procedure to be executed?

I'm puzzled by your comment to mansi where you say you get an error, 'record has already been inserted'.  Does your stored procedure insert a database record?
Avatar of mansi

ASKER

 Dear Markgeer,
      I implemented your suggestions. I tried with making block_proprties
    UPDATE_ALLOWED & UPDATE_CHANGED_COLUMNS both TRUE. I kept     UPDATE_ALLOWED   for item status (which is a base table item) =        TRUE.But still it didn't  work.
        About your first quest. - my stored procedure used do both interest            calculation & update deposit_status.But today I deleted the updating part         from stored procedure & tried to update deposit_status directly from the          forms. But still it didn't work.
      About your second quest.- about error "record has already been                                                   inserted."
     For the deposit_maturing form, the base table is 'Deposit_master'.
      for making the deposit matured I need 4 items.
         1) Acc_no for that particular deposit which is to be matured.(which is                           a base table item)
       2) Maturing date- this is NOT a base table item
       3) Interest_calculated - Not a base table item
       4) Push_button - Calculate
      Now whenever I run the form,
            1) I enter the acc_no to be matured( Naturally it already has to                                               exist in the deposit_master table)
            2)Press button calculate - Then it shows the calculated interest
                               in the interst_calculated field.
      Now after this when I try to exit the form , it asks whether to save the       changes or not. If I say 'yes', It gives the message 'record has already       been inserted'. Even when I explicitely try to update the deposit_master       from forms in 'when_button_pressed' trigger for Calculate button                followed by commit, it gives the same error.       
            So please guide me further.

I see the problem now.  It is:
 "whenever I run the form,
      1) I enter the acc_no to be matured( Naturally it already has to exist in
      the deposit_master table)"

This is a mistake.  DO NOT enter the account number - Oracle will interpret that as an attempt to create (insert) a new account with that number.  Instead, query the account number.  Then when it is displayed, if you update (change) a base table field, a pre-update or post-update trigger can call your stored procedure.

You may want to add deposit_status as a base-table field in the block.  Then you could update it directly and not even need a stored procedure to do that.
Avatar of mansi

ASKER

   Dear Markgeer,
               I implemented your suggestions.I created a new form with base
 table       "deposit_master'. I added 2 other items(not base table items).
  1. push_button  'save'
  2. Amount returned after deposit becomes matured.
      I defined 2 triggers at block level.
  1.  'when_new_block_instance' - here one statement- enter_query;
  2.  'pre_update' - I called stored procedure here. The output
                   field 'amount' was assigned to :amount_returned;
       (note: I deleted the update statement in the stored proc.
              & now I directly update the field in the forms.)

      This is running fine, the status is getting updated even in
  the database  BUT
  even though I call stored proc. in 'pre_update' trigger, The return_amount
  is not shown in the form unless I press 'save' button 'AFTER' updating
  (changing the status field in the forms from 'working' to 'matured') the
   status field.
      Then what is the difference between 'pre_update' and 'post_update'
  trigger?

  ** Here I am changing rather updating the base table item directly
     in forms. Is there no way to update a base table item in the stored
     procedure  in this case? Won't it be more secure as the update is
     at the back-end level.
       So please help me further. Thanks a lot for your help so far.

ASKER CERTIFIED SOLUTION
Avatar of Mark Geerlings
Mark Geerlings
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mansi

ASKER

dear markgeer,
               Thanx a lot for your precious help. I am sorry to be so late. Hope your help in future also.