Home » Developer & Programmer » Forms » master detail data block problem
master detail data block problem [message #165919] Mon, 03 April 2006 05:59 Go to next message
haitham
Messages: 60
Registered: February 2006
Member

i made a master detail data block using the join relationship , the detail data block contains four records ,all i want that when i enter the primary key value in the master data block then the corresponding records in the detail data block are displayed becoz i want to update these records,
note : a master record may have more than one detailed records.

plz help.
Re: master detail data block problem [message #166008 is a reply to message #165919] Tue, 04 April 2006 00:49 Go to previous messageGo to next message
RAS_SANKAR
Messages: 42
Registered: March 2006
Location: India
Member
create key-next-item trigger on primary key field
write the following code

go_block('detailblock');
execute_query;
Re: master detail data block problem [message #166078 is a reply to message #166008] Tue, 04 April 2006 07:17 Go to previous messageGo to next message
haitham
Messages: 60
Registered: February 2006
Member

i made wot u told me but nothing happens ....
wen i write the primary key value in the master data block and go to the detail data block put the cursor to the first field of the first record , nothin displayed althaugh there is related records for that primary key ...i dont know y ..

the form is so simple i can send u the schema script of the tables(2 tables) that are used in the form and the fmx file if u need..
thanks for the first help but plz help me again
Re: master detail data block problem [message #166081 is a reply to message #166078] Tue, 04 April 2006 07:34 Go to previous messageGo to next message
RAS_SANKAR
Messages: 42
Registered: March 2006
Location: India
Member
if u enter primary key value and press tab then only the trigger will fire and display corresponding records in detail block.

if u want to display the details when click in the first record of detail block(after entering the primary key)... then
write 'execute_query' in when-new-block-instance trigger of detail block(in block level)
Re: master detail data block problem [message #166125 is a reply to message #165919] Tue, 04 April 2006 12:08 Go to previous messageGo to next message
RJ.Zijlstra
Messages: 104
Registered: December 2005
Location: Netherlands - IJmuiden
Senior Member
Hi,

Just go to the master block, click there with the mouse, go in enter query mode, enter the PK in the appropiate field, hit execute query and forms will do the rest.

NO FURTHER TRIGGERS, CODING OR WHATEVER NEEDED.

If this does not work, you made a mistake in the relationship you created.

FYI: the master record may have any number of child records, it does not matter at all.

HTH,

Regards,

Rob Zijlstra
Re: master detail data block problem [message #166235 is a reply to message #166081] Wed, 05 April 2006 06:11 Go to previous messageGo to next message
haitham
Messages: 60
Registered: February 2006
Member

thank u it works when i used execute_query in the when-new-block-instance trigger of the detail block level ...
but wot about if i need to dispaly vlaues of some fields of the detailed record and the rest of the fields stay empty ( for data entry )... plz help
Re: master detail data block problem [message #166243 is a reply to message #166235] Wed, 05 April 2006 06:42 Go to previous messageGo to next message
RAS_SANKAR
Messages: 42
Registered: March 2006
Location: India
Member
insert the following code in
When-New-Block-Instance trigger in detail block:
-------------------------------------------------
execute_query;
go_block('detailblock');
while :system.last_record='FALSE' loop
--columns to be null
  :col1 :='';
  :col2 :='';
  ...
  next_Record;
end loop;
:col1 :='';
:col2 :='';
...
Re: master detail data block problem [message #166351 is a reply to message #166243] Wed, 05 April 2006 18:26 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I feel like yelling 'NO, NO, NO' but what RAS_SANKAR has posted MAY work. BUT!! I STRONGLY recommend that you DO NOT WRITE CODE THAT duplicates the standard functionality of Oracle Forms.

Please follow the advice of RJ.Zijlstra. Also Please search 'master detail' in this forum and read the long entries that have been written in the past month or two.

David
Re: master detail data block problem [message #166392 is a reply to message #166243] Thu, 06 April 2006 02:27 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
RAS_SANKAR wrote on Wed, 05 April 2006 13:42

insert the following code in
When-New-Block-Instance trigger in detail block:
-------------------------------------------------
execute_query;
go_block('detailblock');
while :system.last_record='FALSE' loop
--columns to be null
  :col1 :='';
  :col2 :='';
  ...
  next_Record;
end loop;
:col1 :='';
:col2 :='';
...

Nulls should be defined as NULLs and not as zero-length strings. Very bad practice.

MHE
Re: master detail data block problem [message #166395 is a reply to message #166392] Thu, 06 April 2006 02:49 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I believe it is even worse practice to actually 'initialise' them as they are already 'null' and by 'setting' them you set the record_status to 'changed' and cause the When-Validate-Item trigger on each of these fields to fire when you try to leave the record. This is VERY annoying if you decide that you didn't want this extra record. Using this code you will have to manual delete the record, where if you had used normal Oracle Forms processing the empty record doesn't accually exist and it is handled without any code on your part.

David
Re: master detail data block problem [message #166473 is a reply to message #166243] Thu, 06 April 2006 09:08 Go to previous messageGo to next message
haitham
Messages: 60
Registered: February 2006
Member
i used wot u told me ..

execute_query;
go_block('detailblock');
while :system.last_record='FALSE' loop
--columns to be null
:col1 :='';
:col2 :='';
...
next_Record;
end loop;
:col1 :='';
:col2 :='';

but the result was that :
only the specefied fields of the first record are not displayed and the fields of all other recrods are displayed ...
by using debug console i found that the control skips the while loop >> means that the the
:system.last_record=t'true' so the condition returns false so the while loop is not executed .

i tried to use the statement first_record; or go_record(1) before the while loop directly but also returned the same results ...so what i have to do .....
Re: master detail data block problem [message #166474 is a reply to message #166395] Thu, 06 April 2006 09:13 Go to previous messageGo to next message
haitham
Messages: 60
Registered: February 2006
Member
i dont want to display some fields of a detailed rercord .. that wot i want.
but u think that i want not to display some detailed records.
Re: master detail data block problem [message #166540 is a reply to message #166473] Thu, 06 April 2006 20:26 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
"only the specefied fields of the first record are not displayed and the fields of all other recrods are displayed ..." that's because the form displayed ALL the records but your code overwrote the fields in the current record (line 1).

David

[Updated on: Thu, 06 April 2006 20:27]

Report message to a moderator

Re: master detail data block problem [message #166570 is a reply to message #166540] Fri, 07 April 2006 00:42 Go to previous messageGo to next message
RAS_SANKAR
Messages: 42
Registered: March 2006
Location: India
Member
execute_query; 
go_block('detailblock');
while :system.last_record='FALSE' loop
--columns to be null
   :col1 :='';
   :col2 :='';
   ...
   next_Record;
end loop;
:col1 :='';
:col2 :='';

i already tested this code. it is working fine... i didn't know where u got the problem. on which trigger u wrote this code?
Re: master detail data block problem [message #166795 is a reply to message #166235] Sat, 08 April 2006 14:11 Go to previous messageGo to next message
RJ.Zijlstra
Messages: 104
Registered: December 2005
Location: Netherlands - IJmuiden
Senior Member
Hi Haitham,

Sorry for the late reply (crash at home pc and at work no time for this)

You asked the following:
'...
but wot about if i need to dispaly vlaues of some fields of the detailed record and the rest of the fields stay empty ( for data entry )... '

Ok, forget all the other stuff you got about triggers etc. It's not necessary: let the work be done by FORMS, you paid ( or at least your company) a lot of money for it, so use the inbuild possibilities of it and never try to do that yourself.

If you don't want to display the values of some columns, just do not display them. (I hear you thinking now...)
Put some non database items instead for those rows on your form and use these for data entry. In a pre-insert trigger put the values of these fields into the 'normal' columns and your finished.

BUT:
Please explain why you want to put in values in some columns and then not display them? What is the bus. rule for this?

Let me add a word of advice: anytime you got stuck and are trying to solve yoiur problems with a lot of triggers, stand back and look for a minute or even an hour at your problem. (I usually go away from my desk and smoke a cigarette outside the building)
You will be surprised how many times when you do this and return to your computer, you will be solving your 'dark' problem with a few lines of code.

Regards and have a nice weekend,

Rob Zijlstra
Re: master detail data block problem [message #166823 is a reply to message #166570] Sun, 09 April 2006 13:54 Go to previous messageGo to next message
haitham
Messages: 60
Registered: February 2006
Member
i wrote it in the when-new-block-instance...
i used the debug console i found that it didnt enter the while loop means that the last_record is true ,
but only the first record is affected not the last record ..(strange)

anyway i used somethin else easier by not making these feilds as database items ...thats all

but i still need the loop statement to display description about an item of each detailed record .... !!!
Re: master detail data block problem [message #166824 is a reply to message #166795] Sun, 09 April 2006 14:03 Go to previous message
haitham
Messages: 60
Registered: February 2006
Member
hi ..
i want to put in values in some columns and then not display them..becoz its an item purchase request form which contains item_id and qty_received items such that the required quantity are not purchased once but in periods so each time i receve a quantity , add it to the existing received quantity and compare it to the required quantity until they are equal..so i dont want to display a received quantity but i want the user to insert anew quantity to update the record(add it to the existing qty).thats all..

i want to display a description of a displayed item in the detailed record using the when-new-block-instance after execute_query; ,i wrote the following :
while :system.last_record='false' loop
--display a description of the item for the current record
next_record;
end loop;
--display a description of the item for the last record

but the control didnt enter the while loop means that the last_record is true.
and when i wrote the following :

loop
--display a description of the item for the current record
next_record;
exit when :system.last_record='true';
end loop;
--display a description of the item for the last record

this causes an infinite loop means that the last_record is always true....

and this contradicts the previous while loop statement..
y the hell does this happen .... how can i do that ???? give me an idea plz..
Previous Topic: how to get database item property in forms 6i
Next Topic: How to connect database from sql*plus to forms?
Goto Forum:
  


Current Time: Fri Sep 20 06:53:14 CDT 2024