Home » Developer & Programmer » Forms » Master Detail Form Problem (Forms 6i)
icon5.gif  Master Detail Form Problem [message #484191] Sun, 28 November 2010 22:58 Go to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

i want to ask, that in a master detail form, when a user enters few records in detail block against a master record, then when creating a new master record the form builder prompts to save the form first (with yes, no, cancel) option, if we hit no, the records in the detail block are washed away (while the master records remains)

is there any option that i can create several master records having associated detail records before saving them all at the end.

[Updated on: Sun, 28 November 2010 23:00]

Report message to a moderator

Re: Master Detail Form Problem [message #484206 is a reply to message #484191] Mon, 29 November 2010 01:02 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I don't think so. You might try with POST first (when master records change) (instead of COMMIT), and then COMMIT at the end, but I'm not sure it'll work as you'd want it to.
Re: Master Detail Form Problem [message #484222 is a reply to message #484191] Mon, 29 November 2010 02:06 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

well i am not issuing any commit statement. at block level, pls see the attach picture,

in this when i feed master record, then couple of detail records,

then i move back to master block and press the down key (to next record to create another master/detail record) the form builder prompts for save first,

if i hit no, it take to the next record, but when i press the UP arrow key (to return to the previous record) the detail block records are washed away (master record values are preserved)
Re: Master Detail Form Problem [message #484234 is a reply to message #484222] Mon, 29 November 2010 02:32 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
You need to use post.
putting it in when-new-record-instance is simplest.
Re: Master Detail Form Problem [message #484236 is a reply to message #484234] Mon, 29 November 2010 02:45 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

thank you for your quick reply.

should i issue the post command at master level or for each detail level record ?
Re: Master Detail Form Problem [message #484242 is a reply to message #484236] Mon, 29 November 2010 03:01 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
So POST would work, eventually. Great.

Master block level, then.
Re: Master Detail Form Problem [message #484250 is a reply to message #484242] Mon, 29 November 2010 03:41 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

will try and post.
Re: Master Detail Form Problem [message #484254 is a reply to message #484250] Mon, 29 November 2010 03:50 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
I'd put it on both blocks personally.
Re: Master Detail Form Problem [message #484257 is a reply to message #484254] Mon, 29 November 2010 04:09 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
But, one (master) would post both master and details, wouldn't it? /forum/fa/1600/0/
Re: Master Detail Form Problem [message #484262 is a reply to message #484257] Mon, 29 November 2010 04:15 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
It would. I just find it easier to post each record as you go.
That way you can do things like duplicate checks with select statements as all the relevant data is in the DB rather than spread between it and the form.
Re: Master Detail Form Problem [message #484267 is a reply to message #484262] Mon, 29 November 2010 04:25 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
True. Got it.
Re: Master Detail Form Problem [message #484274 is a reply to message #484267] Mon, 29 November 2010 05:22 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

one thing more for knowledge.

if issuing post (on each row of detail), it saves data in data base without commit,

what if user issues a clear record and what if issues a delete record operations ?
Re: Master Detail Form Problem [message #484278 is a reply to message #484274] Mon, 29 November 2010 05:47 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Well post causes oracle to issue either an insert or update statement to the DB for all records that need inserting/updating. Delete_record issues a delete statement. It works fine with post.
clear record behaves the same as always.
Re: Master Detail Form Problem [message #484292 is a reply to message #484278] Mon, 29 November 2010 07:32 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

thanks,
i tried the post builtin, but i am receiving an error messages
that record has already been updated by another user execute query again on detail block.

since post is applied at every record of detail, so this occurs...

in my case there is master detail-1 detail-2 option

so i have to use post on detail-1 level to save detail-2 level records.

even if i apply post on detail-2 level block, on returning to detail-1 block, it issues the same error that record has been updated.

pls note i am using a loop in when button pressed trigger to auto populate the values in detail-1 and for each record of detail-1, several records in detail-2 block.

Re: Master Detail Form Problem [message #484294 is a reply to message #484292] Mon, 29 November 2010 07:39 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
"record has been updated by another user" isn't caused by post, you'd get it on commit if you didn't use post.
Do you have any DB triggers on the tables the datablocks are based on?
If so try setting the DML Return Values datablock property to yes.
Re: Master Detail Form Problem [message #484302 is a reply to message #484294] Mon, 29 November 2010 08:09 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

well i am using dml return array yes.

if you try (on master-detail)

master : form like
detail : tabular like

create master record
go to detail block,
enter one record and hit F10

then create another record on detail and then hit f10 , you'll see this message that record has been updated by another user.

========================
the detail-2 level block has a id generation trigger at database level

Re: Master Detail Form Problem [message #484303 is a reply to message #484302] Mon, 29 November 2010 08:15 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
itech wrote on Mon, 29 November 2010 14:09
well i am using dml return array yes.

The property is called "DML Returning Value". Is that what you are talking about or something else?

itech wrote on Mon, 29 November 2010 14:09

if you try (on master-detail)

master : form like
detail : tabular like

create master record
go to detail block,
enter one record and hit F10

then create another record on detail and then hit f10 , you'll see this message that record has been updated by another user.

I won't you know. I've coded plenty of forms with a master/detail relationship like that and I know how to avoid that error.

Why are you hitting F10 all the time? What have you got it defined as?


edit: missing word.

[Updated on: Mon, 29 November 2010 08:16]

Report message to a moderator

Re: Master Detail Form Problem [message #484304 is a reply to message #484303] Mon, 29 November 2010 08:21 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

yes, DML returning value,

i wrote f10 just to tell how to generate the error.
============

perhaps i could not convey my actual problem, will try and post later.
Re: Master Detail Form Problem [message #484306 is a reply to message #484304] Mon, 29 November 2010 08:47 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
I understand the problem.
What you need to understand is that db triggers are the most common cause of this problem, which is why DRML returning usually fixes it.
The alternative causes (which I'm trying to remember) involve unusual form design. You will not get this error on any master/detail form - you have to do specific things to cause it.
Do you have an post-insert/update triggers?

You should probably also explain this in more detail:
Quote:

pls note i am using a loop in when button pressed trigger to auto populate the values in detail-1 and for each record of detail-1, several records in detail-2 block.
Re: Master Detail Form Problem [message #484361 is a reply to message #484306] Tue, 30 November 2010 00:38 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

i was able to fix that problem by having DRML = yes for all data blocks,
however i have changed the way records were being fetch and inserted.

=======
in the pic, you'll see that there is a fetch button...

in this examination module the master record contains campus/class/subject fields

detail-1 block contains students in that class + obtained marks, and detail-2 block contains A,B,C,D, remarks for several variables for each student.

what i was doing is to assist the data feeder to just press the fetch button to populate all fields automatically with default values for all students (provided the master record fields are filled).

currently, i changed the way records are feeded, on button pres i issue select statements for detail-1 and detail-2, then in the end just issue post then execute-query to get data from database...

now it just gives me a Message that 1 Record Applied and Saved (thats of Master Block record)
can i avoid that message ??

[Updated on: Tue, 30 November 2010 00:40]

Report message to a moderator

Re: Master Detail Form Problem [message #484368 is a reply to message #484361] Tue, 30 November 2010 01:23 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Change :system.message_level
Re: Master Detail Form Problem [message #484377 is a reply to message #484368] Tue, 30 November 2010 01:54 Go to previous messageGo to next message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

i was thinking to do that, but do u think that this is a standard approach ?

i mean, (in general practice) if we do any DML in some trigger, and issues post; or commit;

forms default message alert is non-voidable ? and the only way is to Suppress it by using system.message_level.

or there are any alternate advise on this ?

thank you.

actually i am asking this , as you are experienced and can guide correctly in this regard.
Re: Master Detail Form Problem [message #484387 is a reply to message #484377] Tue, 30 November 2010 04:15 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
itech wrote on Tue, 30 November 2010 07:54
i was thinking to do that, but do u think that this is a standard approach ?

Yes
itech wrote on Tue, 30 November 2010 07:54

i mean, (in general practice) if we do any DML in some trigger, and issues post; or commit;

You do realise that if you do DML in trigger then post won't do anything? Post tells the form to issue DML for any changes in datablocks.
DML in triggers does just that - issues the statement straight away to the DB, so there is nothing for post to do in that regard.
Commit still commits of course.

itech wrote on Tue, 30 November 2010 07:54

forms default message alert is non-voidable ? and the only way is to Suppress it by using system.message_level.

Yes

itech wrote on Tue, 30 November 2010 07:54

or there are any alternate advise on this ?

Well after your second sentence I'm no longer completely sure what approach you are using. But basically there are two:
1) Fill in the datablock items directly, use post to apply the values to the DB.
2) Write an insert statement to insert the data directly in the DB then use execute query to populate the datablock - post does nothing in this case.

The problem with the second approach is that commit_form - default save functionality - won't work unless the user makes subsequent changes. This is because commit_form checks to see if any changes have been made to any database items in any blocks. If there are no changes it does nothing.
Querying data, regardless of how it got in the DB, doesn't count as changed as far as forms is concerned.
Re: Master Detail Form Problem [message #484396 is a reply to message #484387] Tue, 30 November 2010 05:09 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Cookiemonster

The problem with the second approach is that commit_form - default save functionality - won't work unless the user makes subsequent changes. This is because commit_form checks to see if any changes have been made to any database items in any blocks. If there are no changes it does nothing.

In that case, one could use
standard.commit;
as it bypasses any checking and does what you've said: commit!
Re: Master Detail Form Problem [message #484398 is a reply to message #484396] Tue, 30 November 2010 05:25 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
You could, but:
a) I'm not a big fan of bypassing standard commit functionality. You would need to put that in key-commit
b) If you exit the form without saving (or do anything that would cause the data to be flushed from the block - execute query for example) then it will not ask you if you want to save changes.

The second point is the big issue.
Re: Master Detail Form Problem [message #484400 is a reply to message #484398] Tue, 30 November 2010 05:33 Go to previous message
itech
Messages: 173
Registered: May 2008
Location: Fsd, Pakistan
Senior Member

Thank you cookie monster & little foot,
had gained from the discussion!
Previous Topic: Webutil_file_transfer.client_to_as
Next Topic: number of records retrived in the blcok
Goto Forum:
  


Current Time: Thu Sep 19 13:56:28 CDT 2024