Home » Developer & Programmer » Forms » Populating three data blocks with two 1:N relationships (Forsm 6i)
Populating three data blocks with two 1:N relationships [message #361376] Wed, 26 November 2008 02:48 Go to next message
sindikalac
Messages: 52
Registered: November 2008
Location: Europe
Member
Hi, here is the story.

I have three tables, table1, table2 and table3. Relationship between table1 and table2 = 1:n, also table1 and table3. The same thing is with data blocks, I based data blocks on the above tables, db1, db2 and db3.

I created one canvas and placed all tree data blocks on that canvas.

The problem is, I would like to populate all data blocks on the same canvas. I tried it with WHEN-NEW-FORM-INSTANCE on the form level, it didn't work. How can I populate this, because I have in db2 and db3 many records, and in db1 just one record connected to those records in db2 and db3.
Re: Populating three data blocks with two 1:N relationships [message #361443 is a reply to message #361376] Wed, 26 November 2008 07:38 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If I understood what you are saying, this could be a walkthrough (use Data Block Wizard, don't code anything by yourself!)

- create block based on the first table
- create block based on the second table
- create relationship between block_1 and block_2

- create block based on the third table
- create relationship between block_1 and block_3

- run the form. Press EXECUTE QUERY; if corresponding records exist, all blocks will be populated at once.
Re: Populating three data blocks with two 1:N relationships [message #361531 is a reply to message #361443] Wed, 26 November 2008 15:59 Go to previous messageGo to next message
sindikalac
Messages: 52
Registered: November 2008
Location: Europe
Member
I have problem with this. I created as you said dblocks using wizard, and relationships were created.

In db1 there is ID, which is the same as ID in db2 and db3. Blocks are connected via ID.

Now, I have form1 and form2. I pass from form1 ID to form2 as parameter. Form2 is the form with those three data blocks. And I want to populate form2 when jumping from form1 to form2. I mean how to populate just those records related to specific ID, for example ID=2 (ID which I passed as a parameter value);

I tried it with WHEN-NEW-FORM-INSTANCE writing Execute_Query. Before that I assigned parameter value to ID. And just db1 and db2 were populated with records, db3 was not populated. Any suggestion how to do this?
Re: Populating three data blocks with two 1:N relationships [message #361566 is a reply to message #361531] Thu, 27 November 2008 00:33 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Everything you've done looks all right to me.

However, check whether there are 2 relations: "db1_db2" and "db1_db3". If not, the second one might be missing which results in an empty block.

I have created a sample form based on Scott's schema, and it works properly. Here's the FMB file; compare it with your solution.

Finally, perhaps there are no records having the same ID in DB3?
Re: Populating three data blocks with two 1:N relationships [message #361589 is a reply to message #361566] Thu, 27 November 2008 01:58 Go to previous messageGo to next message
sindikalac
Messages: 52
Registered: November 2008
Location: Europe
Member
Unfortunately, I couldn't run the form, because I use Forms 6i, but thank you a lot, I used it to compare property palletes.

It seems all fine, I noticed when I changed order of data blocks in data blocks tree (Object navigator), for example, initial order is:

db1
db2
db3

and I switch db2 with db3:

db1
db3
db2

then just db1 and db3 populate, before the swith those were db1 and db2. I will continue to try...
Re: Populating three data blocks with two 1:N relationships [message #361734 is a reply to message #361589] Thu, 27 November 2008 18:31 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Do you have two 'relations' defined?

David
Re: Populating three data blocks with two 1:N relationships [message #361819 is a reply to message #361734] Fri, 28 November 2008 03:00 Go to previous messageGo to next message
sindikalac
Messages: 52
Registered: November 2008
Location: Europe
Member
djmartin wrote on Thu, 27 November 2008 18:31
Do you have two 'relations' defined?

David


Yes sir I have: db1_db2 and db1_db3. One more interesting situation: When I base data relate db2 and db3 to separate canvases, it works. When I put all three tables (data blocks) on one canvas it won't work.
Re: Populating three data blocks with two 1:N relationships [message #361828 is a reply to message #361819] Fri, 28 November 2008 03:30 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Strange ... I don't have Forms 6i so I can't try it, but that definitely sounds strange. What does canvas have to do with the issue?!?
Re: Populating three data blocks with two 1:N relationships [message #362358 is a reply to message #361828] Tue, 02 December 2008 00:49 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
You DO have the blocks defined in the order db1, db2, and db3 don't you? Have you modified the generated code at all? If yes, I suggest starting again with a new form. Create the blocks, db1, db2, db3. Then create the 'relations' db1_db2, db1_db3.

David
Re: Populating three data blocks with two 1:N relationships [message #379097 is a reply to message #362358] Sun, 04 January 2009 17:02 Go to previous messageGo to next message
sindikalac
Messages: 52
Registered: November 2008
Location: Europe
Member
djmartin wrote on Tue, 02 December 2008 00:49
You DO have the blocks defined in the order db1, db2, and db3 don't you? Have you modified the generated code at all? If yes, I suggest starting again with a new form. Create the blocks, db1, db2, db3. Then create the 'relations' db1_db2, db1_db3.

David


Your suggestion helped me to solve the problem, I created the form again from the beginning and it works. But here is another problem. I have to use this form, in the way that I open it from another form, and pass a parameter to it.

When I pass a parameter (which is ID number of db1 and also db2 and db3) from form A to form B (that's my form I created again), and when I assign parameter value to ID of db1 in WHEN-NEW-FORM-INSTANCE, and execute query, I don't get all data in the form, just partial ones. When I enter query without passing parameter, I do get all data.

My problem is how to pass that parameter in which I put the ID number of record I want to see in my form.

Re: Populating three data blocks with two 1:N relationships [message #379152 is a reply to message #379097] Mon, 05 January 2009 03:03 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
when I assign parameter value to ID of db1 in WHEN-NEW-FORM-INSTANCE, and execute query ...

Try not to do that in the WHEN-NEW-FORM-INSTANCE trigger, but in the PRE-QUERY trigger.
Re: Populating three data blocks with two 1:N relationships [message #379275 is a reply to message #379152] Mon, 05 January 2009 16:14 Go to previous message
sindikalac
Messages: 52
Registered: November 2008
Location: Europe
Member
Littlefoot wrote on Mon, 05 January 2009 03:03
Quote:
when I assign parameter value to ID of db1 in WHEN-NEW-FORM-INSTANCE, and execute query ...

Try not to do that in the WHEN-NEW-FORM-INSTANCE trigger, but in the PRE-QUERY trigger.


Thank you man! God bless you! This worked fine. I assigned a value in PRE-QUERY and put execute_query in WHEN-NEW-FORM-INSTANCE trigger.
Previous Topic: Getting error ORA-01847:day of month must be between 1st and last day of month
Next Topic: Custom "logon" form
Goto Forum:
  


Current Time: Sat Dec 10 14:19:11 CST 2016

Total time taken to generate the page: 0.08152 seconds