Home » Developer & Programmer » Forms » Master-detail form / WHEN-NEW-ITEM-INSTANCE trigger problems
Master-detail form / WHEN-NEW-ITEM-INSTANCE trigger problems [message #310964] Thu, 03 April 2008 00:00 Go to next message
spmano1983
Messages: 269
Registered: September 2007
Senior Member
Friends,

I have master-detail form. master (dept) and detail (emp).
i have one custom table that is tab1(empno,hike);
That empno is same empno only, and hike is sal+1000 for every employee. These both are non database item in emp block.
Suppose if i query dept 10 in runtime. then all 10 department details records are coming perfectly with calculated salary (text item hike). If i save, then i want this details record should be store into my custom table tab1, that is this employee number with hike salary (sal+1000). But here 1st detail record only stored. Except 1st record not stored in table. How i can do? Any loop i should uuse? In which trigger i can do this?, pls give your suggestion on this.

Thanks
Mano

[MERGED by LF; please, do not open a new topic for an old problem. Continue discussion in existing one.]

[Updated on: Fri, 04 April 2008 06:22] by Moderator

Report message to a moderator

Re: Master-Details Form [message #311042 is a reply to message #310964] Thu, 03 April 2008 05:16 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
How exactly do you plan to save records into 'tab1' table? Every time you save changes in this form you want to insert a new record into it? Or, would you like to do that only for changed records? Is 'tab1' "insert only" table, or will you sometimes update existing records (or even delete them)?

As I see it, you provided too few information, but you might consider use of the database trigger which would handle business requirements (once you know them).
Re: Master-Details Form [message #311058 is a reply to message #310964] Thu, 03 April 2008 05:33 Go to previous messageGo to next message
spmano1983
Messages: 269
Registered: September 2007
Senior Member
Hi little foot,

Thanks for your reply. I want to insert that empno and calculated salary (hike Salary) only.

Thanks
Mano
Re: Master-Details Form [message #311190 is a reply to message #311058] Thu, 03 April 2008 12:12 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
So, did you "consider use of the database trigger which would /forum/fa/1597/0/"? If so, how does it look like? Why does it not do what you'd like it to?
when-new-item-instance problem [message #311379 is a reply to message #310964] Fri, 04 April 2008 05:29 Go to previous messageGo to next message
spmano1983
Messages: 269
Registered: September 2007
Senior Member
Friends,

I have three blocks dept,emp,block1.

dept and emp is master-detail relationship (deptno). if i query 10 deptno then its coming all the 10 department in second block.

in the thrid block i have one trigger when-new-item-instance, its having

begin
go_block('emp');
first_record;
loop
insert into mano_tab values(:emp.empno,:emp.sal+100,null);
go_block('emp');
exit when :system.last_record='TRUE';
message(:system.last_record);
next_record;
end loop;
exception
when others then
null;
end;

Every salary for employee (emp block) i have calculated with 1000 rs and store in mano_tab custom table. that is what i wrote this above codes. Its working fine. But i have to move the cursor to that corresponding text item. then only i will fire. I want, when i query 10 record, that same time my calculation should be calculated and stored also. I am looking that when-new-item-instance fires only on input focus only. any way to write this codes in any trigger? i tried in another trigger also. But its giving error (go_block restricted). Pls send your suggestions.

Thanks
Mano
Re: when-new-item-instance problem [message #312035 is a reply to message #311379] Mon, 07 April 2008 20:02 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Have you considered having a when-button-pressed trigger on an item based on 'block1'? In it have a single go_block then the loop and insert statment (you don't need the second go_block). Then all you have to do is press the button.

What happens if the button is pressed a second time?

David
Previous Topic: OC4J error, help please
Next Topic: Customized toolbar...........execute query problem.....??
Goto Forum:
  


Current Time: Fri Sep 27 10:27:08 CDT 2024