Question

"ORA-01779: cannot modify a column which maps to a non key-preserved table"

Asked by: wasabi3689

I create a block called "media_request_info". I create a view "xx_media_request_master_info_v" for its base table. When click on the button to open media_request_info form and try to edit data and save it. It pop up the ""ORA-01779: cannot modify a column which maps to a non key-preserved table"

cannnot allow me to save

How to fix it?

CREATE OR REPLACE FORCE VIEW apps.xx_media_request_master_info_v (
 
         license_number
        ,license_id 
        ,inventory_item_id
        ,licensed_products_id
        ,source
        ,status
        ,requested_date
        ,in_progress_date
        ,completed_canceled_date
        ,batch_number
                                            )
AS
 
 
select
xui.license_number
,xui.license_id
,xuid.inventory_item_id
,xuid.licensed_products_id
,xui.source
,xuid.status
,xuid.s1_date requested_date
,xuid.s3_date in_progress_date
,xuid.s6_date completed_canceled_date
,xuid.ship_batch_id batch_number
 
from
xx_upgrade_inputs xui,   
xx_upgrade_input_details xuid   
where
xui.upgrade_input_id = xuid.upgrade_input_id
and xui.action = 'SHIP'
and xui.status IN ('IN_PROGRESS','REQUESTED','CANCELED')

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-01-14 at 21:04:33ID24053496
Topics

PL / SQL

,

Oracle 8.x

,

Oracle Database

Participating Experts
2
Points
0
Comments
27

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. data migration, foreign key preservation
    Dear all, I have two databases in different sql server installation, with exactly the same schema. These databases work for the same company but different location , and not connected (its a network problem). The database have tables which have many primany keys generated b...
  2. Question on ReDim Preserve !
    1) Why marked line in the following code cause error '9' or subscription out of range?! 2) After solving this problem, is there anyother thing should I consider to make sure dynamic array will work fine? Thanks, ak 'PUBLIC Array Dim names() As String Private Sub Comm...
  3. Need to preserve double quotes on hidden values
    I'm creating an employee survey for my company and I'm dynamically pulling questions and answers from the database. I'm also inserting text areas so users can type their own answers. Unfortunately I think if a user is inserting double or single quotes in their answers the...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: kretzschmarPosted on 2009-01-14 at 23:29:11ID: 23381196

sounds like a non editable view . . .

you could use an instead-of-trigger on the view to manage your modifcations
or
if forms is used an on-update-trigger on the block you have


meikl ;-)

 

by: wasabi3689Posted on 2009-01-15 at 14:35:55ID: 23388619

I don't have experience for instead-of-trigger. Can you tell me how to do it? I provide the view above. How to modify my view to suit as instead-of-trigger.

"If if forms is used an on-update-trigger on the block you have" how to do that in this approach

 

by: kretzschmarPosted on 2009-01-16 at 01:48:49ID: 23391441

well,

you have first to include your keyfields into your fieldlist of your view

in your case it would be
upgrade_input_id for your mastertable

and i guess there will be an additonal field in your detail-table (maybe position)
or maybe it is already in the your fieldlist

could be this inclusion could be enough for oracle to handle updates without additional action (depends on the version),

if not, the you could attach an instead-of-trigger to your view

a sceleton:

CREATE OR REPLACE TRIGGER your_schema.your_trigger_name
  INSTEAD OF INSERT OR UPDATE OR DELETE  --for all cases of dml
  ON your_schema.your_view_name   FOR EACH ROW
BEGIN
   -- you can only insert / update values, which are part from the view,
   -- all others, which are not included in the view, may have constant-values,
   -- or must be calculated/retrieved before on another way
  IF INSERTING THEN
   --maybe any handling for getting a sequence-value before
    INSERT INTO MasterTable (Field1, Field2, . . .) VALUES (:new.mField1, :new.mField2,....);
    INSERT INTO DetailTable (Field1, Field2, . . .) VALUES (:new.dField1, :new.dField2,....);
  END IF;
  IF UPDATING THEN
    UPDATE  masterTable set Field1 = :new.mField1, .... WHERE keyfield = :old.mKeyField;
    UPDATE  detailTable set Field1 = :new.dField1, .... WHERE keyfield1 = :old.dKeyField1 and keyfield2 = :old.dKeyField2;
  END IF;
  IF DELETING THEN
    --Detail First
    DELETE FROM detailTable WHERE keyfield1 = :old.dKeyField1 and keyfield2 = :old.dKeyField2;
    DELETE FROM masterTable WHERE keyfield = :old.mKeyField;
  END IF
END;

well, just a sceleton from head, the content you should adjust to your needs

meikl ;-)

 

by: wasabi3689Posted on 2009-01-16 at 09:02:31ID: 23394906

After reading your code, it's above my head. I think I prefer to do it by on-update trigger method. Do you show me detail about it. I think I can pick up since I have a little experience about it.

 

by: wasabi3689Posted on 2009-01-16 at 12:27:52ID: 23397058

Ok, I write the following code on "On-update" trigger but I cannot create the form with following error

Compiling ON-UPDATE trigger on MEDIA_REQUEST_INFO block...
Compilation error on ON-UPDATE trigger on MEDIA_REQUEST_INFO block:
PL/SQL ERROR 103 at line 3, column 1
Encountered the symbol "PROCEDURE" when expecting one of the following:
 "begin" "declare" "exit" "for" "goto" "if" "loop" "mod"
    "null" "raise" "select" "update" "while" <an identifier>
    <a double-quoted string> <a bind variable>
    <a single-quoted SQL string> "<<" "close" "delete" "fetch"
    "lock" "insert" etc.
declare was inserted before "PROCEDURE" to continue.

PL/SQL ERROR 49 at line 9, column 14
bad bind variable 'PARAMETER.program_id'
PL/SQL ERROR 103 at line 2, column 1
Encountered the symbol "END" when expecting one of the following:
 "begin"
Resuming parse at line 44, column 4.


can anyone fix for me? Also, do I need "On-insert" trigger too?


PROCEDURE Update_Row IS
v_prog_id NUMBER;
v_user_id NUMBER;
 
  BEGIN
 
v_prog_id := :PARAMETER.program_id;
v_user_id := FND_PROFILE.Value('USER_ID');
 
UPDATE xx_upgrade_inputs xui
SET
 
xui.license_number  = :media_request_info.license_number
,xui.license_id  = :media_request_info.license_id
,xui.source =:media_request_info.source
 
WHERE xui.upgrade_input_id=:media_request_info.upgrade_input_id
and xui.action = 'SHIP'
and xui.status IN ('IN_PROGRESS','REQUESTED','CANCELED');
 
 
UPDATE xx_upgrade_input_details xuid 
set
 
xuid.inventory_item_id = :media_request_info.inventory_item_id
,xuid.licensed_products_id=:media_request_info.licensed_products_id
,xuid.status=:media_request_info.status
,xuid.s1_date =:media_request_info.requested_date
,xuid.s3_date =:media_request_info.in_progress_date
,xuid.s6_date =:media_request_info.completed_canceled_date
,xuid.ship_batch_id =:media_request_info.batch_number
 
where 
xuid.upgrade_input_id = :media_request_info.upgrade_input_id;
 
 
END Update_Row;
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:

Select allOpen in new window

 

by: HenkaPosted on 2009-01-18 at 23:48:33ID: 23408790

Please, post here your ON_UPDATE trigger.

 

by: wasabi3689Posted on 2009-01-19 at 07:46:02ID: 23411575

I posted it above. I post again below

PROCEDURE Update_Row IS
v_prog_id NUMBER;
v_user_id NUMBER;
 
  BEGIN
 
v_prog_id := :PARAMETER.program_id;
v_user_id := FND_PROFILE.Value('USER_ID');
 
UPDATE xx_upgrade_inputs xui
SET
 
xui.license_number  = :media_request_info.license_number
,xui.license_id  = :media_request_info.license_id
,xui.source =:media_request_info.source
 
WHERE xui.upgrade_input_id=:media_request_info.upgrade_input_id
and xui.action = 'SHIP'
and xui.status IN ('IN_PROGRESS','REQUESTED','CANCELED');
 
 
UPDATE xx_upgrade_input_details xuid 
set
 
xuid.inventory_item_id = :media_request_info.inventory_item_id
,xuid.licensed_products_id=:media_request_info.licensed_products_id
,xuid.status=:media_request_info.status
,xuid.s1_date =:media_request_info.requested_date
,xuid.s3_date =:media_request_info.in_progress_date
,xuid.s6_date =:media_request_info.completed_canceled_date
,xuid.ship_batch_id =:media_request_info.batch_number
 
where 
xuid.upgrade_input_id = :media_request_info.upgrade_input_id;
 
 
END Update_Row;

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:

Select allOpen in new window

 

by: wasabi3689Posted on 2009-01-19 at 14:19:50ID: 23415162

any ideas?

 

by: HenkaPosted on 2009-01-19 at 21:56:02ID: 23417562

The code you have posted ougth to be in a Program Units section of your form.
Then the code of your On-Update trigger will look like this:

Update_Row;

 

by: wasabi3689Posted on 2009-01-19 at 22:04:57ID: 23417596

I don't want to use program unit, I want the code directly dump into On-update trigger. Is it possible? If not, I have to use program unit.

In program unit, I create a procedure called update_row, right? and dump my code into the update_row procedure and call the update_row from update trigger, right?

It will serve the same purpose?

 

by: HenkaPosted on 2009-01-19 at 22:09:23ID: 23417610

If you want to use your code directly in On-Update trigger, then it ought to look like this:

DECLARE
v_prog_id NUMBER;
v_user_id NUMBER;
BEGIN
 
v_prog_id := :PARAMETER.program_id;
v_user_id := FND_PROFILE.Value('USER_ID');
 
UPDATE xx_upgrade_inputs xui
SET
 
xui.license_number  = :media_request_info.license_number
,xui.license_id  = :media_request_info.license_id
,xui.source =:media_request_info.source
 
WHERE xui.upgrade_input_id=:media_request_info.upgrade_input_id
and xui.action = 'SHIP'
and xui.status IN ('IN_PROGRESS','REQUESTED','CANCELED');
 
 
UPDATE xx_upgrade_input_details xuid
set
 
xuid.inventory_item_id = :media_request_info.inventory_item_id
,xuid.licensed_products_id=:media_request_info.licensed_products_id
,xuid.status=:media_request_info.status
,xuid.s1_date =:media_request_info.requested_date
,xuid.s3_date =:media_request_info.in_progress_date
,xuid.s6_date =:media_request_info.completed_canceled_date
,xuid.ship_batch_id =:media_request_info.batch_number
 
where
xuid.upgrade_input_id = :media_request_info.upgrade_input_id;
END;

"In program unit,.....It will serve the same purpose?" - yes.

 

by: kretzschmarPosted on 2009-01-19 at 22:15:33ID: 23417638

well, sorry for delay, was absent.

Henka already told all

just replace

PROCEDURE Update_Row IS

with

DECLARE

there may also a problem with parameter :PARAMETER.program_id
(maybe it does not exist)

meikl ;-)

 

by: wasabi3689Posted on 2009-01-21 at 12:27:07ID: 23433607

Hey, it seems working. But, when I want to save it, I don't see a message saying "....saved" in the tool bar. But it did save
The message popped up when I close the form.

How to let the message popped up in the tool bar when I click "action->save"

second, do I need to put a line "commit;" in each update statement above??

 

by: HenkaPosted on 2009-01-21 at 23:53:40ID: 23437313

If you use default menu then commit; is there and there is no need to change it.

You can also create your own "save button" on the form and put commit; in its's when-button-pressed trigger.
The code of this trigger can look like this:

commit;
message('Changes has been saved.');

 

by: wasabi3689Posted on 2009-01-22 at 13:41:48ID: 23443967

Your recommendation is good. I see the message. Now I comes up another error message after I modify the view and update trigger. I add two tables to the view. When I want to edit a field in the form, it pops up

FRM-40501: ORACLE error: unable to reserve record for update or delete
ORA-01446:cannot select ROWID from view with Distinct, group by, etc

When I remove the distinct in my view's select statement. I compile again. But still doesn't work. It comes up the message below

FRM-40501: ORACLE error: unable to reserve record for update or delete
ORA-01445:cannot select ROWID from a join view without a key-preserved table.

I attached my view and update trigger for you to take a look Can you tell me how to modify my update trigger.

Sending me with attachment will be the best.

I increase the points to 200. I guess this is not easy to solve and I add more requests

 

by: HenkaPosted on 2009-01-23 at 00:24:25ID: 23447238

I thik that the problem is caused by Key Mode Block property. By default it is set to Automatic and help says:
Specifies that Oracle Forms should use ROWID constructs to identify unique rows in the datasource but only if the datasource supports ROWID.

I think that you ought to use Non-Updateable or Updateable.
Plese, read "Key Mode Property" topic in the on-line help.

 

by: wasabi3689Posted on 2009-01-23 at 15:55:41ID: 23454212

Ok, I changed to Updateable

But, unable to creat a form with following two errors

FRM-30050: Block with uniqueness check must have at least one key item.
Block: MEDIA_REQUEST_INFO
Form: XXLICN
FRM-30085: Unable to adjust form for output.
Form not created

How to fix?

 

by: HenkaPosted on 2009-01-25 at 22:35:37ID: 23464492

In your block you ought to set Primary Key property of item (which correspond to primary key) to yes.

 

by: kretzschmarPosted on 2009-01-25 at 22:57:29ID: 23464566

no no,

you must lock yourself, or even decide self to not lock

just provide a code in the On-Lock-Trigger of the Block, like

in case of no locking, place simple

NULL;

here

in case you want to lock the associated rows of your joined tables just place a code like

declare
  keyofmaster number;
  keyofdetail number;
begin
  select keyfieldfrommaster into keyofmaster from mastertable where [yourCondition] for update nowait;
  select keyfieldfromdetail into keyofdetail from detailtable where [yourCondition] for update nowait;
end;

the locks are resolved by commit or rollback

hope this helps

meikl ;-)

 

by: wasabi3689Posted on 2009-01-26 at 07:47:53ID: 23467607

Hi Henka: I set the primary key to true already. it's still the same problem.

kretzschmar:
I created a trigger on-lock in my block medi_request_info and put

null;

I complied it and still the same problem.

For the code you provided above
declare
  keyofmaster number;
  keyofdetail number;
begin
  select keyfieldfrommaster into keyofmaster from mastertable where [yourCondition] for update nowait;
  select keyfieldfromdetail into keyofdetail from detailtable where [yourCondition] for update nowait;
end;

Do I need that in on-lock trigger? How to put it based on my attachment?

If I have on-lock trigger, do I need on-update trigger as well?


 

by: HenkaPosted on 2009-01-26 at 22:12:23ID: 23474078

I am not sure but it seems to me that you can update only one table of view.

 

by: wasabi3689Posted on 2009-01-27 at 07:53:12ID: 23477632

It sounds that we can update multiple tables for a view, right?

 

by: kretzschmarPosted on 2009-01-27 at 08:02:50ID: 23477753

i have no problem to update mutiple tables from a view, using
- an instead of trigger
or
- an on-update/on-Lock-trigger

well, usual on-lock should work, but my knowledge is from the 6i edition.

what version do you use?

meikl ;-)

 

by: wasabi3689Posted on 2009-01-27 at 08:06:49ID: 23477805

I am using 8i database and form version is 11.0.35. I have on-update trigger attached above and you can download and have a look.

I don't understand if you mean I need on-dated trigger also need on-lock trigger, or mean either...or...?

 

by: wasabi3689Posted on 2009-01-27 at 14:37:08ID: 23481961

Hi all,

I have made it working now. The key is to set one of the items in the block as primary key. After I made it, I can change whatever I want and save. I am going to close this ticket and distribute the points fairly.

Also, I want to invite all the experts to help me for the following

http://www.experts-exchange.com/Database/Oracle/PL_SQL/Q_24032174.html

It's relevant to this ticket.

Just need to read the most recent post that I did for the problem. No need to read all.

Thanks a lot.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...