Delete master record if detail records are empty
I have a simple question and response system
the user enters their details (record stored in table called source - pkey as id_src)
the user then goes on to answer questions (in a form)
those responses are kept in a separate table (responses)
with a foreign key in each response row telling me the ID of the source ie fk_id_src
the form has a SUBMIT and CANCEL button
PROBLEM
If a user registers their details (created a source record with an ID)
but fails to answer and questions (the response table does not have any foreign keys to that ID source)
what is the best way to AUTOMATICALLY delete the user record (if there are no detail records in the response table)
(note: the main response form IS NOT an ADDT form)
the checking process needs to be triggered by the CANCEL button
ie if the user presses submit - responses will be made to the questions - ie they will be empy answers - but in this case it is valid to do so
I was wondering about a custom transaction - with delete SQL -
or using check detail records - but cant see how to get that to fire the delete record transaction?
any guidance appreciated
tia
Paul
OK
I can create a separate page that checks if a detail record exists
and display an error if it does
on the same page I can add a delete transaction
pass the master record id
Both work, all OK so far
BUT, the check detail throws its error message if detail records DOES EXIST
I need to allow the delete transaction to run, if detail records DO NOT EXIST
AND then
redirect then page - wether the delete occurs or not
any ideas?
Paul
Similar Messages
-
Use field from file header record in detail records
Hi,
I receive a file with different records type (transmission header, file header, detail records, file footer). The fields in each record type are different. The transmission header tells me who the sender of the file is. I need this information, because I am merging data of various senders into one table.
When processing the files, I need to split each file according to recordtype. (I can not use the same logic for each recordtype). How can I populate an extra column in the detail files with the value from the header record?
What I tried so far is the following:
- Populate a global variable using a script: This does not seem to work in the context of dataflows.
- Create a 'join' between header record and detail record. However there are no fields I can join, so Data Services is not happy with that.
- Store the field value from the header record in a DS (I chose a cache datastore, memory datastore did not work in batch scenario. I feel I can get this to work, but it seems quite an elaborate and expensive solution: First Filter the header record from the file, write the required field to the cache datastore, then read the same file but now filter the detail records, and join this with the datastore.
Is there a better way to do this? I was hoping I could just use a script and read the first line of my file and move the value to a global variable....
It would be great if someone could give me some tips...
Many thanks,
Jan.Hi Werner,
I am not sure if I understand you correctly.
I have declared $State as a global variable, not as a parameter.
When I check my custom function I do get a warning that a variable is called which is not declared.
I thought I did not have to worry about this as the variable does exist within the job where the function is called.
It looks like I can not set a value to a global variable in a custom function.
Is that correct, or is there something wrong with my syntax?
Really the only reason I call a custom function is to set the global variable, so I could even make my function as simple as this:
$State = 'NSW';
Return 0;
It still doesn't work...
Any idea why?
Thanks,
Jan. -
Master Detail module returns to Master page after Detail record saved
Using Oracle Designer Editor version 10.1.2.0.2 I have generated a Web PL/SQL package
set up as a Master/Detail where the Master and Detail records appear in separate windows.
The Master window contains multi-records each with a link to the related Detail records.
The user clicks on the Detail link and the window that appears will allow the user to insert
a new Detail record. Once the user clicks the Save button I need the Detail window to disappear
and the focus returned to the Master records preferably after a new query is performed.
What are the steps I need to perform to navigate back to the Master page and close the Detail
page?
Thanks,
MarkThe simple answer is that to do exactly what you want would take some fundamental changes to the way the framework works. The actionInsert procedure does what it does - it saves the changes and redisplays the form. You can do post-generation changes to make it do something else, like return to the Master, but I'd advise against it.
But if you want a way to return to the Master window, where the user clicks a button or link on the detail form after saving changes, that we can do. Just make a note of the URL that does the initial display of the Master page - probably my_module_name$.startup. Go into the detail module component, and click the User Text tab. Then at Text Location, "Bottom of View Form" (or Top if you want the link there) add for a link:
htf.anchor('my_module_name$.startup','Return to Master')Or for a button:
htf.formOpen('my_module_name$.startup','GET')||htf.formsubmit('Return to Master')||htf.formCloseYou may need to set the SECECS preference for this module to "No" to get this to work.
An alternative to my method is to define an Action Item in the module that does a navigation. I often am linking directly to the View form for a master table, rather than a record list, as you are, and Action Items don't work well for that, but one might work fine for you. -
How to create One Master - and 2 detail records region
Hi,
My requirement is to have three regions on a single page, one for master record and two for detail records.
Also, one detail record region needs to upload images (photos) to database.
Can some one tell me how to do this in APEX.
Thanks
AaliHi Aali, I have the same issue in a master detail form, I don't know how to upload images in the detail form, can you help me please.
Thanks and regards,
Wilson -
ADF 10.1.3: Simultaneous insert of Master and Multiple detail records
Hi,
I'm trying to implement an Insert page (JSP document) having a Master table form and Multiple detail records grid with a Pop up to insert Detail records into the grid.
The user should be able to input Master record details, then Detail records one by one, and finally insert all into the database.
I'm wondering how this could be done using the Drag n drop feature of ADF (with ADF faces, JSF and Toplink) to the maximum extent.
Please give me a rough guideline on how this could be done.
Thanks in advance
VikasAnyone???
-
Empty record in (detail record)
Hello all of you,
i have detail block,, and in that block, it is not necessary to write in all field . i want that when the user fetch the record, the empty field fill with red color,,
is it possible
example
item # | Name | Detail | Qty | Issu_date| Recived_date | Iss_person | Rec_person | etc
10000.|abc.....| ........ |..300|..01-jan-06|.......07-jun-06 |john............|david............|
20000.|xyz.....|NY.... |........|..08-jun-06|.....................|smith..........|................... |
the user enter 20 to 30 record in the detail block
thank alotYou can try this only when you have no other option.
You will have to write three triggers.
1. When-new-form-instance at form level
declare
myvar varchar2(25);
it_id item;
begin
if (:block3.text2) is null then
it_id:=find_item('block3.text2');
Set_Item_Property(it_id,BACKGROUND_COLOR,'r255g0b0');
end if;
end;
2. When-new-item-instance at item level
declare
it_id item;
begin
it_id:=find_item('block3.text2');
Set_Item_Property(it_id,BACKGROUND_COLOR,'r255g255b255');
end;
3. post-text-item at item level
declare
myvar varchar2(25);
it_id item;
begin
if (:block3.text2) is null then
it_id:=find_item('block3.text2');
Set_Item_Property(it_id,BACKGROUND_COLOR,'r255g0b0');
end if;
end;
Message was edited by:
Mayank Parmar -
How to delete the master records when corresponding details records exist.
What is the SQL statement to delete the records of master when the corresponding detail records are present.
Note: No Cascade clause was used at the time of creation of referential integrity constraint.
"M"- Master Table
"D"- Detail Table
I used, "Delete from M cascade". This statement is not working.
Your favour in this will be deeply appreciated.
Cheers
PremChinHi folk,
i appreciate your suggestion,
my crux of the situation is to know whether there is a way to make it without disabling,removing or modifying the referential integrity constraint.
If so, modifying, please help me out how to modify the constraint in order to remove the master records keeping detail records in-tact.
Cheers
Premz -
I have a Master and two details records. I need to generate report for the Master-Details record.
I need to include some details from the Master table and some details from each of the detail tables.
For example :
In Master table: Employee_Number
Employee_Name
Company_Code
Company_Name
In Application Detail table: Application_Code
Application_Name
In Non-Application Details table: Non-Application_Code
Non-Application_Name
I need to include Employee_Name, Company_Name, Application_Name and Non-Application_Name in my report. How should I go about creating the report?and may I know what type of report style should I use?Should I use Tabular or Group Above?
Thank for your helphello,
you might want to start off with a regular master detail layout and then modify the layout manually to fit your needs.
when running throught he wizard, you just select whichever fields you want to display.
regards,
the oracle reports team --pw -
Update issue in the Master records & detail records
Hi
Good Day !
Senario :
I have Master - Details Form , Master Block - A, Detail Block - B
In Master Block i have 10 records, For Each records in the Master will have related records in Detail ,
Requirement :
I want to reset records (some colums) in Master & then its related detail records in detail Block,
After updating the first master record & its detail record the next Master Master reord & its detail records should be updated respectively...
Can any one help on his, Its very urgent...
Below is my sample code... Pls guide me... Thanks in Advance
DECLARE
num_total_records1 NUMBER;
num_loop_i1 NUMBER;
num_total_records2 NUMBER;
num_loop_i2 NUMBER;
BEGIN
GO_BLOCK ('A');
FIRST_RECORD;
LAST_RECORD;
num_total_records1 := TO_NUMBER (NAME_IN ('SYSTEM.CURSOR_RECORD'));
FIRST_RECORD;
FOR num_loop_i1 IN 1 .. num_total_records1
LOOP
UPDATE table_name_1
SET columnA = NULL
WHERE clause
NEXT_RECORD;
END LOOP;
GO_BLOCK ('B');
FIRST_RECORD;
LAST_RECORD;
num_total_records2 := TO_NUMBER (NAME_IN ('SYSTEM.CURSOR_RECORD'));
FIRST_RECORD;
FOR num_loop_i2 IN 1 .. num_total_records2
LOOP
UUPDATE table_name_2
SET columnA = NULL
WHERE clause
NEXT_RECORD;
END LOOP;
commit_form;
END;declare
ln_rownum number;
begin
go_block('TEST_MASTER1');
first_record;
if :TEST_MASTER1.master_id is null then
message('No records selected');
message('No records selected');
raise form_trigger_failure;
end if;
loop
ln_rownum := to_number(:SYSTEM.CURSOR_RECORD);
update test_master1
set master_name = master_name||'Master '||to_char(ln_rownum)||' Updated'
where master_id = :TEST_MASTER1.master_id;
go_block('TEST_DETAILS1');
first_record;
if :TEST_DETAILS1.detail_id is not null then
loop
update test_details1
set DETAIL_NAME_NAME = detail_name_name||'Master '||to_char(ln_rownum)||' Updated'
where detail_id = :TEST_DETAILS1.DETAIL_id;
if :system.last_record = 'TRUE' then
go_block('TEST_MASTER1');
go_record(ln_rownum);
exit;
end if;
next_record;
end loop;
else
go_block('TEST_MASTER1');
go_record(ln_rownum);
end if;
exit when :system.last_record = 'TRUE';
next_record;
end loop;
commit;
clear_block(no_validate);
execute_query;
end;You hae take care of all validations. This is just a simple sample code.. -
Formula field, Detail records not getting updated
Hello seniors,
i need help on 2 issues;
first, Issue No. 1
i have master-detail form with the following tables;
POH master record table
PH_NO pk
PH_PARTY
PH_FXRATE exchange rate
PH_PD_LOCAL_TOT total of PD_LOCAL_AMT from details records
PH_PD_FOREIGN_TOT total of PD_FOREIGN_AMT from details records
POD Detail records table
PD_PHNO fk
PD_ITEM
PD_QTY
PD_PRICE
PD_LOCAL_AMT
PD_FOREIGN_AMT
M_PD_FOREIGN_AMT Formula (PD_QTY * PD_PRICE)
M_PD_LOCAL_AMT Formula (M_PD_FOREIGN_AMT/PH_FXRATE)
CTRL Control block
M_PH_PD_LOCAL_TOT Summary-Sum-Table=POD, Field=M_PD_LOCAL_AMT
M_PH_PD_FOREIGN_TOT Summary-Sum-Table=POD, Field=M_PD_FOREIGN_AMT
Triggers
POH Table
Pre-Insert and Pre-Update
:PH_PD_LOCAL_TOT := :M_PH_PD_LOCAL_TOT
:PH_PD_FOREIGN_TOT := :M_PH_PD_FOREIGN_TOT
POD Table
Pre-Insert and Pre-Update
:PD_LOCAL_AMT := :M_PD_FOREIGN_AMT
:PD_FOREIGN_AMT := :M_PD_LOCAL_AMTThe problem that i am facing is while i UPDATE a record.
whats happening is when the form is in Query mode and if i change a record, lets say
change the value of the field PH_FXRATE, then what happens is, on screen i get all Detail
record's M_PD_LOCAL_AMT Calculated & Updated, but the actual db field PD_LOCAL_AMT remains unchanged
in the database after i press F10 or Save button.
The update takes place for the POH table and form displays 1 Record updated.
whereas if i have for example 4 detail records, then form should update those as well and display finally
5 records updated is'nt it..?
In query mode,if i insert new or modify an existing record in the detail block, then at this point, form marks just
that particular record as CHANGED. Thus making changes at db level only for this particular record.
what i want is once i make changes to the field PH_FXRATE, then form should mark all detail records
as CHANGED and on saving, the PRE-UPDATE tigger of POD table should come in to force and the changes
in the values of M_PD_LOCAL_AMT in turn to the db field PD_LOCAL_AMT should get affected at db level.
i have also tried to put these assignments
:PD_LOCAL_AMT := :M_PD_FOREIGN_AMT
:PD_FOREIGN_AMT := :M_PD_LOCAL_AMT
at PRE-UPDATE of POH table, thinking that form might consider
all detail records, at this point. i noticed that it does it, but only picks
1 record (i guess just the first record always) and change a db level.
No. 2 Issue:
i have put a POST-FORM-COMMIT at form level for auditing the Total fields of POH table against the details records.
Declare
M_LC_AMOUNT NUMBER(13,3);
M_FC_AMOUNT NUMBER(13,3);
Begin
SELECT SUM(PD_LOCAL_AMT) INTO M_LC_AMOUNT
FROM POD
WHERE PD_PHNO = :PD_PHNO;
IF :PH_PD_LOCAL_TOT != M_LC_AMOUNT THEN
:PH_PD_LOCAL_TOT := M_LC_AMOUNT;
END IF;
SELECT SUM(PD_LOCAL_AMT) INTO M_FC_AMOUNT
FROM POD
WHERE PD_PHNO = :PD_PHNO;
IF :PH_PD_FOREIGN_TOT != M_FC_AMOUNT THEN
:PH_PD_FOREIGN_TOT := M_FC_AMOUNT;
END IF;
End;i was testing and notice that in a query mode when all records are displayed.
if i go on changing values on records and save or save later keeping the form open,
form allows, but if 1 come back to a record which i may have changed and saved earlier, then it flashes Error;
"Records has been changed by another user, requery to ..."
i want to do an Audit before final db-Commit and keep the user free from this Error..
Please tell me first of all, is my approach for both of my issues,correct.?
if not, then please suggest what should be changed.
i'll highly appreciate for all your help. TYVM. Regards.I did exactly as you suggested. It works well for new record insertion
but when i press F7 to query it, its flashes messages before displaying detail records
Field must be entered.
Mr. Andreas,
i have problem only when i change value of PH_FXRATE. It re-calculates on screen values for M_PD_LOCAL_AMT
(Formula M_PD_FOREIGN_AMT/PH_FXRATE)
i want the changed value of M_PD_LOCAL_AMT to be saved in the actual db-field PD_LOCAL_AMT.
for this i have PRE-UPDATE on POD Table
:PD_LOCAL_AMT := :M_PD_LOCAL_AMT
:PD_FOREIGN_AMT := :M_PD_FOREIGN_AMT
Which is doing that.It is not marking the detial record as CHANGED.
I tried giving the above assignments in the PRE-UPDATE on POH table.
It saves the changed value in the db-field, but not all detail records, if more than 1.
what you have suggested, will get me acheived what i am looking for..? -
Hey,
I got a problem...
I have a form which has master (say A)and detail (say B) table information displayed. When I query the master the corresponding details records are also displayed in the form. But the details records which are fetched automatically in the form are NOT SORTED out according to my criteria.
Can anybody tell me how to do this???
-GaneshGanesh,
how and where do you set this criteria? Are you setting the order by property on the block?
Frank -
Cannot exit form after on-check-delete-master trigger fires.
Hi
I have a master-detail form.
I have used the default on-check-delete-master trigger that gets generated by forms when creating a relation between master and detail data blocks.
After trying to delete a master record when detail records exists for this master record, I cannot exit the form from a when-button-pressed trigger created in the master block.
I know that the on-check-delete-master trigger fires , which calls the "raise form_trigger_failure" function.
This then prevents me from exiting the form from an exit button that I created.
If I try exiting from the default menu "exit" icon, I first am prompted to save or cancel the changes I have made - even if there are NO changes made to the form.
Plse someone suggest a workaround asap.
ThanksIn the future, please include all related product versions (not product names - we need versions numbers). Without knowing the product version generally we can only guess.
I have tested what you described in Forms 10.1.2.3 (with Forms Bundle Patch 9593176 & 11710576) and it works as expected. The query is cancelled. Given that it works in this version, I suspect it would also work correctly in the latest version which is 11.1.2.0 -
Creating a Master with Two Detail report style
In a Group-Above report data model, how does one add a 2nd detail group appearing at the same hierarchial level as the 1st group?
The report already exists with MASTER and detailA. I need to add detailB and tie it to MASTER just like detailA.
|MASTER|
|detailA||detailB|
\-------/\-------/Amjad,
Thanks for the reply. My question relates to your suggestion #1: How does one create detailB in the data model?
The only thing I have been able to do is to create a 2nd query linked to the 1st query. This makes the data model look like it has two masters each with one detail. What I want is a single MASTER with two details.
Are you suggesting that the only way to accomplish this is by having two queries, one linked to the other, as in the crude rendering shown below?
|MASTER1||MASTER2|
|DETAIL1||DETAIL2|
The above would be displayed in the data model as follows:
|__Q_1___||__Q_2___|
|G_DETAIL1||G_DETAIL2|
\----------------/\----------------/ -
Can't delete master record when matching when matching detail record exist
Hi
on the rel. property:
Delete Record Behaviour = cascading
Prevent masterless Operation =yes
Automatic Query = yesCan't delete Record Master & Detail...
On delete getting error msg.
Can't delete master record when matching when matching detail record exist
am i missing something...!
Regards,
Abdetu...First of all, remember the ripple affect of cascading deletes and updates.
Oracle database allows creating master/detail relationship between tables using foreign keys and allows cascading deletes by defining the FOREIGN KEY constraint with ON DELETE CASCADE clause.
Oracle Forms on the other hand, handle cascade delete thing internally when you set the relation properties.
Now if you have 3 tables with MASTER->DETAIL1->DETAIL2 relationship and you have a form defined with MASTER->DETAIL1 relationship only, it won't let you delete (and save) master or detail record since the third table (DETAIL2) is referencing the rows from DETAIL1 which you are trying to delete.
If DETAIL2 were present on the form, it would have deleted with relation property CASCADING. If you really want that when you delete a master record, all its details should be deleted too, then consider defining FOREIGN KEY constraints with ON DELETE CASCADE and on the form set relation property CASCADING.
And if all master/detail tables are on your form and still it is not allowing you to delete master with cascading, there must be some code preventing it. Check triggers like ON-DELETE, KEY-COMMIT etc what they are doing. -
FRM-40654 error in master-detail form while deleting record in detail block
Hi,
I am facing an issue in a custom form which is a Master-detail form while deleting a record in detail block. It is giving an error "FRM-40654 Record has been Updated by another user. Re-query to see change". I have checked the record is matching with that in database.
Can anyone help on this.
Thanks In Advance,
MidhunHi jan,
master block is based on Table "A" and detail block is based on a View "X".
View "X" definitions includes the tables "A","B","C" etc..
Now I have tried removing table"A" from view "X", even then the same error is ocuuring but the lock is happening on table "B" instead of "A"
Thanks,
Midhun
Maybe you are looking for
-
Reversal of Clearing document (Mass)
Dear Experts, I have given a payment run through F110 (Authomatic Payment Run). Around 700 payment documents has been generated. For some technical reason with HDFC Bank we have to reverse all the payment documents and again payment run has to be pro
-
InDesign-CC: Selection Tools Not Working
When I am moving quickly between tools and objects, all of a sudden the tool gets stuck on the hand tool and will not change or function. I have looked into multiple reasons. It is not prefs/cache or anything like that. I also thought maybe my wirele
-
Problem with Indesign interactive button
Hi Everyone! (Work on Tiger/CS3/Acrobat 8.0) I am making a PDF with interactive button, (behavior- open file/ all my files are in the same folder and I doesn't move it) When a make all my button and export in PDF it's work, but I made some mistakes (
-
How do I get my Norton Antivirus Protection gadget back onto the Mozilla toolbar?
I have the Norton Antivirus and before I downloaded the new Mozilla Firefox 4, I had a Norton gadget. It would tell me whether or not my searches were safe and etc.
-
Intel iMac won't play Real Audio samples from Amazon
I know this problem could reside with Amazon or Real Audio, but the Apple forum seems the place where knowledgeable and helpful folks hang out, so here goes ... I've got a brand-new Intel iMac. Going to Amazon, I can no longer listen to sound samples