Home » Developer & Programmer » Forms » How to populate a multi record block (merged 2) (Oracle Forms 10 g)
How to populate a multi record block (merged 2) [message #505434] Tue, 03 May 2011 02:19 Go to next message
oracle_qns
Messages: 9
Registered: May 2011
Junior Member
Hi,

I need help for this situation

i have two blocks called BLOCK1 AND BLOCK2
BLOCK1 is a multi record block with a field, FIELD_A
BLOCK2 is a multi record block with fields FIELD_B,FIELD_C,FIELD_D

i have a button on BLOCK1 called 'FETCH'.
The requirement is when_button_pressed on 'FETCH'
BLOCK2 must be populated for each record of BLOCK1.
Population logic is based on, values from a database table TABLE_A which has got
column values corresponding to all fields of BLOCK1 and BLOCK2.

Please guide me to write this code
Re: How to populate a multi record block [message #505450 is a reply to message #505434] Tue, 03 May 2011 03:39 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This looks like a standard master-detail form. Doesn't matter that both blocks are based on the same table.

Therefore: use Data Block Wizard, create both blocks, let Wizard create all necessary triggers and procedures that will be responsible for maintaining relationship between those two blocks. Once the Wizard does its job, no further code is necessary (from your side), i.e. you don't have to code anything (regarding the master-detail relationship).
Re: How to populate a multi record block (merged 2) [message #505451 is a reply to message #505434] Tue, 03 May 2011 03:39 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Why not just define a relationship between the 2 blocks and let forms default query mechanism take care of everything?
Re: How to populate a multi record block (merged 2) [message #505486 is a reply to message #505451] Tue, 03 May 2011 06:14 Go to previous messageGo to next message
oracle_qns
Messages: 9
Registered: May 2011
Junior Member

Hello friends ,

Thanks for the fast replies.
I created the master detail relationship with the 2 blocks.
It works, but all my requirement has not been met.

For eg :

If i enter value1 on first field and value2 on second field of Block_A,and clicks 'FETCH' button
am not getting the results for both values in BLOCK_B. Instead Block_B will populate result only for the Block_A record where the cursor is seen.

the only logic which i have added in when_button_pressed trigger of 'FETCH' is :
GO_BLOCK('BLOCK_B');
EXECUTE_QUERY.

Please comment ..
Re: How to populate a multi record block (merged 2) [message #505493 is a reply to message #505486] Tue, 03 May 2011 06:29 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Right; well, this is because you would like to change Forms' built-in querying features.

This is how it "normally" goes:
  • in master block, enter query mode
  • enter search criteria
  • execute query
  • detail records are displayed in a detail block
I think I know what you want - you'd like to enter more than one value in master block and fetch detail records for all those masters. If so, good news for you - you still don't have to code anything (which means: remove the "Fetch" button; master block can be a single record block). You should learn how to use Forms' capabilities. In your case, this is what you have to do:
  • in master block, enter query mode
  • enter ":a" into master block's item (colon + a, omit quote signs). "a" is a variable name, so you can use anything you want. This is just an example.
  • execute query
  • a new window will be opened. In there, you can write condition that will return desired records. For example, you'd write
    :a in ('first_value', 'second_value')
    where 'first_value' and 'second_value' are values you previously (regarding your previous message) entered into the first and second item in master block
  • click <OK>
  • detail block will contain all records that belong to both 'first_value' and 'second_value' master block values
Re: How to populate a multi record block (merged 2) [message #505502 is a reply to message #505493] Tue, 03 May 2011 06:51 Go to previous messageGo to next message
oracle_qns
Messages: 9
Registered: May 2011
Junior Member
Hi

thanks for the reply.
Your understand is exactly what i need.
Since my form has to follow some predefined features. we cannot use the default standard form menu n all . Beacuse my requirement here is as per a design which i cannot change, therefore 'FETCH' button has to be there . It would be very helpful if you could lead me ahead with this specific requirement.

Re: How to populate a multi record block (merged 2) [message #505503 is a reply to message #505502] Tue, 03 May 2011 06:59 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If that's the case, I'm afraid that you'll have to do the whole job manually (what a pity!). Executing a query is not an option here, so you'll have to loop through all records in master block, write another loop to SELECT ... INTO detail records. Don't forget NEXT_RECORD (otherwise, you'll keep overwriting the first record all the time).

Tedious job, I suppose. It's a shame that "predefined features" go against built-in features of a tool you chose to use.
Re: How to populate a multi record block (merged 2) [message #505535 is a reply to message #505503] Tue, 03 May 2011 09:11 Go to previous message
oracle_qns
Messages: 9
Registered: May 2011
Junior Member
Hi,

Appreciates all your support. it's working , the tedious way Smile .
Previous Topic: Oracle Developer 6 Download
Next Topic: Read set of files from a directory
Goto Forum:
  


Current Time: Tue Sep 17 03:16:55 CDT 2024