|
|
Question : Oracle Forms : How to populate checkboxes dynamically from the database
|
|
|
|
Hello,
I need to populate checkboxes in the Oracle Forms from the database. I have database table structure as follows:
PEOPLE ( PEOPLEID,FNAME,LNAME) insert into PEOPLE(PEOPLEID,FNAME,LNAME) VALUES(11111, 'ANDY', 'ADAMS'); insert into PEOPLE(PEOPLEID,FNAME,LNAME) VALUES(22222, 'BRIAN', 'BANK'); insert into PEOPLE(PEOPLEID,FNAME,LNAME) VALUES(33333, 'CAROL', 'CAMPS');
PEOPLE_INTERESTS(PEOPLEID,INTERESTID)
insert into PEOPLE_INTERESTS(PEOPLEID,INTERESTID) VALUES(11111,'AAA'); insert into PEOPLE_INTERESTS(PEOPLEID,INTERESTID) VALUES(11111,'CCC'); insert into PEOPLE_INTERESTS(PEOPLEID,INTERESTID) VALUES(33333,'CCC'); insert into PEOPLE_INTERESTS(PEOPLEID,INTERESTID) VALUES(33333,'BBB');
"INTERESTS_TYPE (INTERESTID,INTERESTSTYPE) insert into INTERESTS_TYPE(INTERESTID,INTERESTS) VALUES('AAA', 'AGRICULTURE'); insert into INTERESTS_TYPE(INTERESTID,INTERESTS) VALUES('BBB', 'BOOKS'); insert into INTERESTS_TYPE(INTERESTID,INTERESTS) VALUES('CCC', 'COMPUTER'); insert into INTERESTS_TYPE(INTERESTID,INTERESTS) VALUES('DDD', 'FINANCE');
I would like to show these 4 checkboxes on the form. In the form, when user search for 'ANDY ADAMS', the out of four checkboxes,''AGRICULTURE'' and 'COMPUTER' checkboxes should be checked. User should be allow to edit these checkboxes. When creating new records, these 4 checkboxes should be avaliable to user.
I will really appreciate if if anybody could give me some ideas on how to achieve this. I am new to forms, my knowledge of forms is very limited.
Thanks,
|
|
|
|
Answer : Oracle Forms : How to populate checkboxes dynamically from the database
|
|
For this sort of behaviour with a limited but possible changing number of possibilities I would choose the following approach, that requires just a few changes from default behaviour of oracle forms. Create a temporary table create global temporary table cartesian_check ((PEOPLEID (same type as other), interest_id (same type as other), INTERESTS (same type as other), checked varchar2(1)) ON COMMIT PRESERVE ROWS;
define the child block on the temporary table and mark it as only updateble ; only the columns interests and checked have to visible , and only checked is updateble in the pre-quiry trigger of the child block delete from cartesian_check; insert into cartesian_check select :masterblock.people_id, interest_id, INTERESTS, (select decode(count(*),0,'N','Y') from people_interest PI where PI people_id = :master.people_id and PI.interest_id = it.inertestid) checked from interests_type IT;
in the on_update trigger if checked = 'N' then delete from people_interest PI where PI people_id = :people_id and PI.interest_id = :interest_id; end if; if checked = 'Y' then insert into interests_type IT select :people_id, :interest_id from dual -- prevent changing from Y to N to Y from inserting a second record WHERE NOT EXISTS (SELECT 1 FROM people_interest PI where PI people_id = :people_id and PI.interest_id = :interest_id) end if;
|
|
|
|