Home » Developer & Programmer » Forms » Post Query Trigger (Oracle8i and Form6i)
Post Query Trigger [message #497694] Sun, 06 March 2011 20:59 Go to next message
mkhalil
Messages: 108
Registered: July 2006
Location: NWFP Peshawar Pakistan
Senior Member
Dear Collegues,

I am very thankfull to all of you that your guidance has always solved my problems and i gaind knowledge from your expertise.

Now i have another problem for which i have searched the board but is unable to solve it so far.

Here is the code
declare
	currec varchar2(100) := :system.cursor_record;
--	runbal number;
begin
	if currec = '1' then
		:gsubldgr.balance := nvl(nvl(:gsubldgr.credits,0) - nvl(:gsubldgr.charges,0),0);
		:global.runbal := nvl(:gsubldgr.balance,0);
	else
		:gsubldgr.balance := :global.runbal + (nvl(:gsubldgr.credits,0) - nvl(:gsubldgr.charges,0));
		:global.runbal := nvl(:gsubldgr.balance,0);
	end if;
end;

I have placed this code on key-next-item of a text item placed before the above three items i.e. charges,credits and balance.

At the time of data entry this code is working well but at the time of query it does not work but only execute the first expression of if statement whereas i have copy and past the same trigger in Post-Query trigger of the block.

Where is the problem? Would any one can help me.

Muhammad Khalil
Re: Post Query Trigger [message #497727 is a reply to message #497694] Mon, 07 March 2011 00:07 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
KEY-NEXT-ITEM probably works. However, if user navigates to next item with mouse, KEY-NEXT-ITEM won't fire. Therefore, perhaps you should consider moving that code into WHEN-VALIDATE-ITEM trigger instead.

As of querying: I think that :SYSTEM.CURSOR_RECORD is a culprit. What happens if you modify it to :SYSTEM.TRIGGER_RECORD (in both KEY-NEXT-ITEM (or WHEN-VALIDATE-ITEM) and POST-QUERY triggers)?
Re: Post Query Trigger [message #497838 is a reply to message #497727] Mon, 07 March 2011 08:21 Go to previous messageGo to next message
mkhalil
Messages: 108
Registered: July 2006
Location: NWFP Peshawar Pakistan
Senior Member
Well done littlefoot. It working fine with :system.trigger_record in post-query trigger. Thanks a lot.

I used when-validate-item instead of key-next-item but when i delete a record the cursor not exit from the item if all records have been deleted. Is any solution for such problem.
Re: Post Query Trigger [message #497963 is a reply to message #497838] Mon, 07 March 2011 23:21 Go to previous messageGo to next message
mkhalil
Messages: 108
Registered: July 2006
Location: NWFP Peshawar Pakistan
Senior Member
Perhaps i can't explain my view point clearly.
First i used when-validate-item trigger instead of key-next-item. It was working fine but when i delete one by one all records in the block. After deletion of last record the cursor did not exit from the text item to which when-validate_item trigger was attached, therefore, i copy the code to key-next-item trigger. Is there any solution so that i may again use the when-validate-item trigger instead of key-next-item.
Re: Post Query Trigger [message #497977 is a reply to message #497963] Tue, 08 March 2011 00:13 Go to previous message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
It seems that code you wrote (and posted in your first message) should be moved into a procedure.

Then you'd call that procedure whenever appropriate (in WHEN-VALIDATE-ITEM, KEY-DELREC, etc. triggers).
Previous Topic: Date and Time Validation
Next Topic: Reading and Writing data in a text file.
Goto Forum:
  


Current Time: Tue Sep 17 16:23:10 CDT 2024