Home » Developer & Programmer » Forms » Post Query Trigger with cursor
Post Query Trigger with cursor [message #488859] Tue, 11 January 2011 15:03 Go to next message
im99_chs
Messages: 14
Registered: November 2006
Junior Member
Good afternoon to all of you!

I need your help. I create a master detail form. I created also a post quey trigger, inside I wrote the code below.
A cursor looks to another table and returns to the form some values i need!
declare 
  cursor C1 is 
    select apofaa, startdate, enddate, transport
    from trapofdet
    where trapofdet.apofcode = :trapof.apofcode;
begin
  open C1;
  loop
    fetch C1
      into :TRAPODOSI_NEW_NEW.APOFAA, 
           :TRAPODOSI_NEW_NEW.STARTDATE, 
           :TRAPODOSI_NEW_NEW.ENDDATE, 
           :TRAPODOSI_NEW_NEW.TRANSPORT;
    exit when C1%notfound;
    
    next_record;
  end loop;
  close C1;
  first_record;
  null;
end;

How to solve the
a. frm-40737, illegal restricted procedure go block in post-query trigger
b. It seems tha returns all the records but it appears only the last one.

Please can anybody help with these?
Thanks in advance!
Christos

[EDITED by LF: formatted code and applied [code] tags]

[Updated on: Tue, 11 January 2011 15:48] by Moderator

Report message to a moderator

Re: Post Query Trigger with cursor [message #488862 is a reply to message #488859] Tue, 11 January 2011 15:50 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I suppose that simple
select apofaa, startdate, enddate, transport
  into :TRAPODOSI_NEW_NEW.APOFAA, 
       :TRAPODOSI_NEW_NEW.STARTDATE, 
       :TRAPODOSI_NEW_NEW.ENDDATE, 
       :TRAPODOSI_NEW_NEW.TRANSPORT
  from trapofdet
  where apofcode = :trapof.apofcode;
would suffice.
Re: Post Query Trigger with cursor [message #488863 is a reply to message #488862] Tue, 11 January 2011 17:31 Go to previous message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
You've misunderstood when post-query fires. It fires once for each record returned by a query. Not once for the block/query. Hence a cursor loop is not needed. Consequently the next_record/first_record aren't needed either - which is just as well since they're not allowed in post-query.
Consequently LF's code is all that is needed. Though if the that query does return multiple records you're going to need to change the where clause to something more restrictive - ie get the data for the current record in the block only.
Previous Topic: frm-41051
Next Topic: forms
Goto Forum:
  


Current Time: Wed Sep 18 19:56:00 CDT 2024