| ORA-01732 error message when updating a table... [message #148165] |
Tue, 22 November 2005 23:57  |
crmoffat
Messages: 33 Registered: November 2005 Location: Australia
|
Member |
|
|
Hi all
I have a table in a database (think it's oracle 9.something) called DPIP.DEDUCTIONS. I am trying to run a statement like this in some VB code
UPDATE DPIT.DEDUCTIONS SET END_DATE = '01-DEC-05' WHERE EMPLOYEE# = '09039351' AND PAYCODE = 'EVBIN';
and I keep getting the error message ORA-01732 Data manipluation on this table not legal on this view.
I would have thought this message would have been reserved only for views (and this to the best of my knowledge is a table!). If I go into the front end I can update the table no problems, just not using this update statement? Anybody have any ideas as to why I might be getting this error message
regards
cameron
|
|
|
|
|
|
|
|
|
|
| Re: ORA-01732 error message when updating a table... [message #148195 is a reply to message #148165] |
Wed, 23 November 2005 01:03   |
sudhir.sukumar
Messages: 52 Registered: August 2005 Location: India
|
Member |
|
|
Most likely you are trying to update on a VIEW which is based on TABLEs that are joined.
I was trying to replicate your error (almost there) and found the following.
scott@TESTDB> desc staff
Name Null? Type
---------- ------- ---------
EMPNO NOT NULL NUMBER(10)
ENAME VARCHAR2(1000)
STATUS NOT NULL VARCHAR2(10)
scott@TESTDB> desc staff_details;
Name Null? Type
----------- -------- ---------
DESIGNATION VARCHAR2(1000)
ENAME VARCHAR2(1000)
JOIN_DATE DATE
scott@TESTDB> select * from staff;
EMPNO ENAME STATUS
----- ------ -------
123 ABC ACTIVE
456 DEF INACTIVE
789 GHI ACTIVE
scott@TESTDB> select * from staff_details;
DESIGNATION ENAME JOIN_DATE
----------- ------ ----------
ACCOUNTANT ABC 12/12/2004
DRIVER DEF 22/06/2004
scott@TESTDB> CREATE OR REPLACE VIEW ABC AS
2 SELECT S.EMPNO EMPNO, S.ENAME ENAME, S.STATUS STATUS,
3 D.DESIGNATION DESIG, D.JOIN_DATE J_DATE
4 FROM STAFF S, STAFF_DETAILS D
5 WHERE S.ENAME = D.ENAME
/
View created.
scott@TESTDB> UPDATE abc
2 SET j_date = '01-JAN-2003'
3 WHERE empno = 456
4 /
set j_date = '01-JAN-2003'
*
ERROR at line 2:
ORA-01779: cannot modify a column which maps to a non key-preserved table
Missing referential integrity between the joined tables can be the reason for this error.
Regards
Ps: Sorry, did'nt see the previous posts.
[Updated on: Wed, 23 November 2005 01:06] Report message to a moderator
|
|
|
|
| Re: ORA-01732 error message when updating a table... [message #148291 is a reply to message #148165] |
Wed, 23 November 2005 07:49   |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
| crmoffat wrote on Wed, 23 November 2005 00:57 |
UPDATE DPIT.DEDUCTIONS SET END_DATE = '01-DEC-05' WHERE EMPLOYEE# = '09039351' AND PAYCODE = 'EVBIN';
|
Bad move there.
Why do people insist on setting a date column to a character string? What year is that? 0005, 1905, 2005?
Watch:
alter session set nls_date_format='DD-MON-YYYY';
select to_char(to_date('01-DEC-05'),'mm/dd/yyyy') from dual;
TO_CHAR(TO
----------
12/01/0005
|
|
|
|
| Re: ORA-01732 error message when updating a table... [message #148382 is a reply to message #148165] |
Wed, 23 November 2005 21:15  |
crmoffat
Messages: 33 Registered: November 2005 Location: Australia
|
Member |
|
|
Thanks all for assistance...
Unfortunately the db is provided externally (through an Application service provider), so the set up of the date format is a bit out of my hands (which is a pain as the odd time we bulk upload data it comes from various peoples spreadsheets and the date formatting always causes problems...I usually use the format(date, "dd-mmm-yyyy") in my vb code on any date variables I use in select / update statements)
toad application seemed really helpful...at least now I can have a look at the database before I write scripts...before it was guesswork at times!
cheers
cameron
|
|
|
|