Home » Developer & Programmer » Forms » Problem working with Parent-Child Block
icon5.gif  Problem working with Parent-Child Block [message #134650] Thu, 25 August 2005 23:53 Go to next message
yash1000
Messages: 22
Registered: August 2005
Junior Member
Hi Guys,

I am having a problem working with Parent-Child relationship. I am using Oracle Form 4.5.

I am having two blocks say DEPT(parent) and EMP(Child). When the user click on DEPT.DEPTNO it populates child record. What I want to do is to add a bit of rule. i.e when the user click on DEPT.DEPTNO field and select value 10,it should disable all child records whose EMP.JOB='MANAGER'.

I would really appreciate any help on this.

Many thanks,

YASH

Re: Problem working with Parent-Child Block [message #134654 is a reply to message #134650] Fri, 26 August 2005 00:20 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Yash,

Review set_item_instance_property. In the Post-Query trigger of your child (detail) block you can test the value of 'JOB' and if it is 'MANAGER' you can turn UPDATE_ALLOWED 'off', REQUIRED 'off', etcetra.

Please consider searching this forum for 'set_item_instance_property' and see what other people have done.

David

Re: Problem working with Parent-Child Block [message #134656 is a reply to message #134654] Fri, 26 August 2005 00:35 Go to previous messageGo to next message
yash1000
Messages: 22
Registered: August 2005
Junior Member
Hi David,

Thanks for your reply. One thing I forget to mention is that Dept and Emp are control block and the record in EMP(child) block is populated programatically. So in that case will your above solution work.

Thanks,

Yash
Re: Problem working with Parent-Child Block [message #134657 is a reply to message #134654] Fri, 26 August 2005 00:39 Go to previous messageGo to next message
yash1000
Messages: 22
Registered: August 2005
Junior Member
Hi David,

Lastly set_item_instance_property built-in does not exist in form 4.5. Any alternate solution to my problem.

Cheers,

yash
Re: Problem working with Parent-Child Block [message #134659 is a reply to message #134656] Fri, 26 August 2005 00:43 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Put the test logic and 'set_item_instance_property' commands in the place where you populate the child block. I don't know whether it will work, but I expect that it will. In 13 years of Oracle programming I have never created or worked on a form which was populated purely programmatically.

David
Re: Problem working with Parent-Child Block [message #134662 is a reply to message #134657] Fri, 26 August 2005 00:45 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
In the When-New-Record-Instance trigger on the EMP block, try testing the 'job' and if 'MANAGER' do a 'next-record'.

To be complete, you will have to know whether the user is going 'up' or 'down' and test if the current record to be 'jumped', if going 'up' is the next to first and if going down is the next to last.

David

Update: You can always program the 'Pre-Update' trigger to fail on 'MANAGER' records unless the user has a particular 'status'.

Sorry, I forgot that you have non-database blocks. Just do whatever processing you would do for a normal update and if it is a 'MANAGER' reject it. In the When-Validate-Item for each item, test the 'job' and do a raise form-trigger-failure when necessary.

[Updated on: Fri, 26 August 2005 01:11]

Report message to a moderator

Re: Problem working with Parent-Child Block [message #134893 is a reply to message #134662] Sun, 28 August 2005 18:17 Go to previous messageGo to next message
yash1000
Messages: 22
Registered: August 2005
Junior Member
Hi David,

Thanks for giving me head on to my problem. Could you pls elborate more on your explanation as I could not figure out which built-in should I use in when-new-record-instance in order to disable the records whose job is manager.

Do not hestitate if you need any further clarification.


Thanks,

Yash
Re: Problem working with Parent-Child Block [message #134903 is a reply to message #134893] Sun, 28 August 2005 19:20 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Have you considered testing the status of the user in the where clause through which you are populating your block and if the user has access then show the 'MANAGER' records but if they don't have the correct status then don't put the 'MANAGER' records in your block?

In your 'UP' trigger put :global.direction := 'UP' (plus the UP command) and in your 'DOWN' trigger put :global.direction := 'DOWN'. Then in the When-New-Record-Instance have
begin
   if :blk.position = 'MANAGER' then
      If :global.direction = 'UP' then
         if :system.cursor_record = 1 then
            raise form_trigger_failure;
         else
            up;
         end if;
      else   /* assume 'DOWN' */
         if :system.last_record = 'TRUE' then
            raise form_trigger_failure;
         else
            down;
         end if;
      end if;
   end if;
end;

See if this works for you.

David
Previous Topic: replacing one column value between two rows..help??
Next Topic: ...Active X Control
Goto Forum:
  


Current Time: Fri Sep 20 03:28:37 CDT 2024