Home » Developer & Programmer » Forms » post_query
post_query [message #138270] Wed, 21 September 2005 01:42 Go to next message
VSPB
Messages: 27
Registered: August 2005
Junior Member
hello
i am getting a problem in post query trigger. i have 2 forms. one shows the list of all vendors. There are 4 buttons on it. new - new entry
edit - editing the selected record from the list
delete - to delete the record
exit.
when i click new a new form for vendor_registration is displayed. and when i click edit the form with the details of the selected vendor_id is displayed. but when i click edit it shows the message 'do you want to save the changes'. and this started coming after i wrote post-query trigger as below for 3 blocks -
vendor_category

post-query trigger

-- to show category_name as it is a non-database item. there can be more than 1 categories.

DECLARE
  CURSOR c1(vid NUMBER) IS 
    SELECT a.category_name
    FROM   item_category_m a,
           vendor_category b
    WHERE  a.item_category_code = :vendor_category.category_id
           AND b.vendor_id = vid;
BEGIN
  IF :vendor_category.category_id IS NOT NULL  THEN
    FOR i IN c1(:vendor_m.vendor_id) LOOP
      :vendor_category.category_name := i.category_name;
    END LOOP;
  END IF;
EXCEPTION
  WHEN OTHERS THEN
    NULL;
END;

and same code is written in the post-query trigger of vendor_sub_category and vendor_item_m to show sub_category_name and item_name. i have read other topics in your forum relating to this('do you want to save the changes you have made?') but it didnt work in my case.

there is a relation between vendor_category and vendor_sub_category as
vendor_category.category_id=vendor_sub_category.category_id;

and between vendor_sub_category and vendor_item_m as
vendor_sub_category.sub_category_id=vendor_item_m.sub_category_id;

vendor_m is the master table and is related to the above three tables by vendor_id.

form-level triggers are
when-new-form-instance
on-clear-details
fileuploader-callback

vendor_m block triggers are
pre-insert
on-populate-details
on-check-details-master
post-query

in above mentioned three blocks there are the triggers related to relations and a pre-insert trigger to auto-generate primary key.

hope this information helps. i am still trying to solve it. but still if i could get some solution from the forum it would be helpful.

Thank you...

Mod-Upd: Reformat code

[Updated on: Wed, 21 September 2005 18:32] by Moderator

Report message to a moderator

Re: post_query [message #138418 is a reply to message #138270] Wed, 21 September 2005 18:38 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Why are you using a'loop' in your post-query trigger? If you are expecting only a single row to be returned then a simple 'open', 'fetch', '%found', 'close' may be more approprate. Please note that where the pre-query fires only once for the block, the post-query trigger fires for each RECORD.

The reason for the 'do you want to save?' message is that you appear to be populating a data based field in your post-query, that is, :vendor_category.category_name. If it IS a data based field then consider only populating it when IT is null.

I will need to think a bit more about whether the pre-insert is the best place for the primary key to be generated. It is okay for the subordinate tables but not for the parent table.

Hope this helps. Get back to us.

David
Previous Topic: how To Create Status bar
Next Topic: applying enter query logic
Goto Forum:
  


Current Time: Fri Sep 20 05:27:27 CDT 2024