Check if details exist before saving master record.. [message #628056] |
Wed, 19 November 2014 10:09 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/2a941b1a8dac27cd2e347647c8c37edb?s=64&d=mm&r=g) |
nait1234
Messages: 29 Registered: August 2013 Location: Edmonton
|
Junior Member |
|
|
I have a form that has a master block that lets you enter multiple records. When one of these master records has a "code" field populated with a specific value, the details block needs to have at least one row entered in it as well (you can enter more than one detail row... if not for that, this would be easy to do).
So I've been spinning my wheels to try and find a way to have the form check to see if details exist before saving a master row to the database. I've tried a variety of things. I've mostly been trying to figure out a trigger where this would make sense and to be able to iterate or count the rows sitting in the detail block for that specific master record that is about to be saved.
I can't use GO_BLOCK within the pre-insert, pre-update, commits, etc, of the master record, as that is not a legal function to call in these triggers. So that prevents me from being able to do anything I've thought about (using LAST_RECORD, or checking the value of a field in that block against null, or using COUNT_QUERY against this block).
Does anyone have any ideas? Is this possible? Of course the big problem is it's sort of a "chicken before the egg" thing, where you can't have any detail committed in the database of course without the master existing first, and the requester of this change wants the form to enforce that details have been entered (at least one row) if the master has been saved as a specific code.
I appreciate any help anyone can give, but I'd like to avoid anything too overly complicated, if possible (if it gets to be something that will be a lot of work, I'll push to not have this requirement in place).
Thanks!
|
|
|
|
|
|
Re: Check if details exist before saving master record.. [message #628075 is a reply to message #628072] |
Wed, 19 November 2014 16:57 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/2a941b1a8dac27cd2e347647c8c37edb?s=64&d=mm&r=g) |
nait1234
Messages: 29 Registered: August 2013 Location: Edmonton
|
Junior Member |
|
|
Actually I have one thought, I'll try. That is to use the WHEN-NEW-RECORD-INSTANCE trigger of master block.. if they switch records, it will check the count and force them to put in some details first if count is 0. I'll see if that works for me. I think this will miss scenarios, possibly.. not sure. but it is definitely a step in the right direction.
EDIT: OK, that sucks, that didn't work, because "WHEN-NEW-RECORD-INSTANCE" fires after the record has changed, meaning it's now looking at the next record (irrelevant to the situation).. maybe PRE-RECORD? Will try that.
[Updated on: Wed, 19 November 2014 17:00] Report message to a moderator
|
|
|
Re: Check if details exist before saving master record.. [message #628153 is a reply to message #628075] |
Thu, 20 November 2014 08:42 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/6f539f43889b4b3e3fcb6c591073de8f?s=64&d=mm&r=g) |
CraigB
Messages: 386 Registered: August 2014 Location: Utah, USA
|
Senior Member |
|
|
Quote:EDIT: OK, that sucks, that didn't work, because "WHEN-NEW-RECORD-INSTANCE" fires after the record has changed, meaning it's now looking at the next record (irrelevant to the situation).. maybe PRE-RECORD? Will try that.
Actually, the When-New-Record-Instance: Fires when the input focus moves to an item in a record that is different than the record that previously had input focus. Specifically, it fires after navigation to an item in a record, when Oracle Forms is ready to accept input in a record that is different than the record that previously had input focus. This trigger fires whenever Oracle Forms instantiates a new record.
If you want your code to execute when a user navigates to the block as well as when they navigate to a new record in the block, perhaps a combination of the When-New-Block-Instance trigger and the When-New-Record-Instance trigger is what you need. Just write a procedure that can be called from both triggers.
Craig...
|
|
|
|
Re: Check if details exist before saving master record.. [message #628177 is a reply to message #628159] |
Thu, 20 November 2014 16:25 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](//www.gravatar.com/avatar/1229663c86eb1a441385fe710cd9116e?s=64&d=mm&r=g) |
mughals_king
Messages: 392 Registered: January 2012 Location: pakistan
|
Senior Member |
|
|
i used PRE-INSERT trigger in Master block and i found 100% Ressult is your requirement is different thn this below code?? just see in the image.
DECLARE
A VARCHAR2(20);
BEGIN
:SYSTEM.MESSAGE_LEVEL := '20';
A := GET_RECORD_PROPERTY(1,'a1_dtl',STATUS);
IF NOT FORM_SUCCESS THEN
A := 'NEW';
END IF;
:SYSTEM.MESSAGE_LEVEL := '0';
IF A = 'NEW' THEN
MESSAGE('Enter Detail Rercord First');
MESSAGE('Enter Detail Rercord First');
RAISE FORM_TRIGGER_FAILURE;
END IF;
END;
Regard
Mughals
[Updated on: Thu, 20 November 2014 16:59] Report message to a moderator
|
|
|