Home » Developer & Programmer » Forms » Button trigger filling multiple fields in detail-form ? (10g, DB 10g XE)
Button trigger filling multiple fields in detail-form ? [message #409710] Tue, 23 June 2009 10:14 Go to next message
ICTstudent
Messages: 5
Registered: June 2009
Location: holland
Junior Member
hello guys Smile

Im trying to create a button that replaces all the entries of a single column with the same entry, which is the ID of the highest entry from another column.

So, I put a button down on the form with a "When_button_pressed" trigger with the following pl/sql code:

BEGIN
IF :kavel.kavelid IS NOT NULL THEN
SELECT bod.bodid
into :kavelbod.bodid
FROM bod
where bod.kavelid = :kavel.kavelid
HAVING :kavelbod.bedragf = MAX(:kavelbod.bedragf)
GROUP BY bod.bodid;
end if;
-- een join van bod en kavel want kavel heeft geen bodid
EXCEPTION
when no_data_found then
message( 'Geen data gevonden' );
raise form_trigger_failure;
END;

Now the problem is that there are multiple boxes that need to be filled, and this trigger can only fill one. any ideas?
Re: Button trigger filling multiple fields in detail-form ? [message #409714 is a reply to message #409710] Tue, 23 June 2009 10:21 Go to previous messageGo to next message
djbabu
Messages: 14
Registered: May 2009
Junior Member

One idea is to assign "Number of Items Displayed" property to 1..

Re: Button trigger filling multiple fields in detail-form ? [message #409716 is a reply to message #409714] Tue, 23 June 2009 10:47 Go to previous messageGo to next message
ICTstudent
Messages: 5
Registered: June 2009
Location: holland
Junior Member
thanks for replying!
Well, I dont want to fill just one item, but a column Smile

What I'm trying to do is creating a button that is supposed to replace all "bodID" entries in the detail part of the form with the "bodID" of the highest amount of money ("bedragf") offered for an item.

here is an image of the detail part of the master-detail form im trying to do this with:
f.imagehost.org/0377/knopje.jpg

Every row is a bid on an item. The one with the highest bid (highest bedragf), needs to have it's bodid placed in every field of the bodid column.

Im clueless about how i should achieve this :s

[Updated on: Tue, 23 June 2009 10:48]

Report message to a moderator

Re: Button trigger filling multiple fields in detail-form ? [message #409719 is a reply to message #409710] Tue, 23 June 2009 11:04 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
You need to loop over the records.
Go to the first and then use next_record until you reach the last.
Re: Button trigger filling multiple fields in detail-form ? [message #409721 is a reply to message #409710] Tue, 23 June 2009 11:14 Go to previous messageGo to next message
ICTstudent
Messages: 5
Registered: June 2009
Location: holland
Junior Member
so something like

go_block('KAVELBOD');
first_record;
LOOP

IF :kavel.kavelid IS NOT NULL THEN
SELECT bod.bodid
into :kavelbod.bodid
FROM bod
where bod.kavelid = :kavel.kavelid
HAVING :kavelbod.bedragf = MAX(:kavelbod.bedragf)
GROUP BY bod.bodid;
end if;

EXIT WHEN :sytem.last_record = 'TRUE';
next_record;
end loop;

Would this work? Assuming the last two columns in the picture are from the 'KAVELBOD' block?
Re: Button trigger filling multiple fields in detail-form ? [message #409722 is a reply to message #409710] Tue, 23 June 2009 11:34 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Looks ok - try it.
Can't see the picture by the way.
Re: Button trigger filling multiple fields in detail-form ? [message #409742 is a reply to message #409722] Tue, 23 June 2009 17:18 Go to previous messageGo to next message
ICTstudent
Messages: 5
Registered: June 2009
Location: holland
Junior Member
oh, thats because I cant post pictures yet (less than 5 posts)

here is the url without http: //

f.imagehost.org/0377/knopje.jpg

Re: Button trigger filling multiple fields in detail-form ? [message #409765 is a reply to message #409742] Tue, 23 June 2009 23:20 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Have you considered doing an 'update', followed by a 'standard.commit', and then an 'execute_query' to redisplay the records?

No looping necessary.

David
Re: Button trigger filling multiple fields in detail-form ? [message #409884 is a reply to message #409765] Wed, 24 June 2009 06:26 Go to previous messageGo to next message
ICTstudent
Messages: 5
Registered: June 2009
Location: holland
Junior Member
To be honest, I havent. Im an extreme novice at this, and although the commands you mention sound somewhat familiar, I have no idea what to do with them Sad
Re: Button trigger filling multiple fields in detail-form ? [message #409933 is a reply to message #409710] Wed, 24 June 2009 09:15 Go to previous messageGo to next message
djbabu
Messages: 14
Registered: May 2009
Junior Member
I don't think 'execute_query' will work for this scenario.

Re: Button trigger filling multiple fields in detail-form ? [message #409962 is a reply to message #409710] Wed, 24 June 2009 10:29 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
It will if you update the data on the database with an update statement as djmartin suggested.
Previous Topic: Tree for the forms
Next Topic: Acknowledge please
Goto Forum:
  


Current Time: Fri Apr 26 01:01:47 CDT 2024