Ora 2309 - atomic NULL violation on SRID update
Hi all,
I'm trying to update an SRID value for a layer using:
Update COUNTRY c set c.SHAPE.SDO_SRID = 8307;
I get the following error :
Error: ORA 2309
Text: atomic NULL violation
The value of SRID is NULL. Why this doesn't work for COUNTRY ? (and works for another table!)
Thanks.
Francois
Hi,
You probably have a country with a NULL geometry.
To make the update work, use this SQL:
Update COUNTRY c set c.SHAPE.SDO_SRID = 8307
where c.shape is not null;
siva
Similar Messages
-
ORA_02309 Atomic NULL violation
Hi all,
When I try to update the folowing i get an error message:
update adressen_geom T
set T.coordgeocodepoint.sdo_srid=90112;
Now error ORA_02309 occurs.
So if i choose to name the objecttype like somerwhere else in this forum and write it like this:
update adressen_geom T
set T.coordgeocodepoint.sdo_srid=mdsys.sdo_geometry(90112);
it says ora00932 inconsistent datatypes: expected number got mdsys.sdo_geometry
Now i don´t understand it anymore please helpHave never used spatial, but the error simply means that you're attempting to reference a property of an object, where the object does not yet exist (has not yet been instantiated).
When inserting the object, you need to instantiated it - even if the properties are null. The following code demonstrates the error and the correction.
SQL> create or replace type TTestObject is object
2 (
3 n number,
4 s varchar2(4000)
5 );
6 /
Type created.
SQL> create table test_objects
2 (
3 id number,
4 obj TTestObject
5 )
6 /
Table created.
SQL> insert into test_objects values (1, null );
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL> select * from test_objects;
ID OBJ(N, S)
1
SQL> update test_objects t
2 set t.obj.n = 123
3 where t.id = 1;
set t.obj.n = 123
ERROR at line 2:
ORA-02309: atomic NULL violation
SQL> insert into test_objects values( 2, TTestObject(null,null) );
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL> select * from test_objects;
ID OBJ(N, S)
1
2 TTESTOBJECT(NULL, NULL)
SQL> update test_objects t
2 set t.obj.n = 123,
3 t.obj.s = 'Test'
4 where t.id = 2;
1 row updated.
SQL> commit;
Commit complete.
SQL>
SQL> select * from test_objects;
ID OBJ(N, S)
1
2 TTESTOBJECT(123, 'Test')
SQL>If this is unclear, please say so and I will add more detail and explanation to this example. -
Hi all,
In which case the following error message can occur.
What is the problem in this Update statement.Please expertise.
SQL> UPDATE SA_CUSTOMER_ADDL_ADDRESS_DTLS A
2 SET A.CAA_ADDRESS_INFO.COLUMN6_L = 1
3 WHERE A.CAA_ADDRESS_TYPE_CODE = 2
4 /
SET A.CAA_ADDRESS_INFO.COLUMN6_L = 1
ERROR at line 2:
ORA-02309: atomic NULL violationrow is having null value. check for it.
-
I am getting "Ora-02309" atomic null violation on updating SRID below.
Update my_Table C
set C.Geometry.SDO_SRID=2958;
It has null/no value of SRID in Geometry.
some people say to "Initiating your object before you access it" but I am not sure how to di it.
Thanks
Nancy.Please validate you geometries using VALIDATE_GEOMETRY_WITH_CONTEXT. If you have invalid geometries fix it before update the SRID. Is there a spatial index on the geometry column? If yes here are the steps to perfom the update:
1. Fix invalid or null geometries
2. drop the spatial index
3. update user_sdo_geom_metadata (SRID)
4. update geometry srid
5. create spatial index
Arnd -
Regarding ORA-00001: unique constraint violation error
Hi ,
This is Venkat. I am new to OWB.
When I run the mapping I am getting the ORA-00001: unique constraint violation error.
My loading type is Update/Insert.
My target table Primarykey is combination of 3 keys.
Please give me the suggestions. It is very urgent.
Thanks,
Venkat1) If you can disable/drop the indexes on the table, you can load the data and then do a SQL query grouping by the PK/UI to show which rows have a count > 1 i.e. the duplicates.
2) If you can't alter the target table, perhaps create a dummy copy of the table without pk/indexes and load to that and then do above query.
3) Run the mapping via the debugger and set a breakpoint just before your target table and examine the data to see if you can spot the duplicates.
4) Put a deduplicator into the mapping (just before target table), this may allow you to load data but doesn't solve the real problem as to why you have duplicates.
Si -
ORA-01456 : may not perform insert/delete/update operation
When I use following stored procedure with crystal reports, following error occurs.
ORA-01456 : may not perform insert/delete/update operation inside a READ ONLY transaction
Kindly help me on this, please.
My stored procedure is as under:-
create or replace
PROCEDURE PROC_FIFO
(CV IN OUT TB_DATA.CV_TYPE,FDATE1 DATE, FDATE2 DATE,
MSHOLD_CODE IN NUMBER,SHARE_ACCNO IN VARCHAR)
IS
--DECLARE VARIABLES
V_QTY NUMBER(10):=0;
V_RATE NUMBER(10,2):=0;
V_AMOUNT NUMBER(12,2):=0;
V_DATE DATE:=NULL;
--DECLARE CURSORS
CURSOR P1 IS
SELECT *
FROM FIFO
WHERE SHARE_TYPE IN ('P','B','R')
ORDER BY VOUCHER_DATE,
CASE WHEN SHARE_TYPE='P' THEN 1
ELSE
CASE WHEN SHARE_TYPE='R' THEN 2
ELSE
CASE WHEN SHARE_TYPE='B' THEN 3
END
END
END,
TRANS_NO;
RECP P1%ROWTYPE;
CURSOR S1 IS
SELECT * FROM FIFO
WHERE SHARE_TYPE='S'
AND TRANS_COST IS NULL
ORDER BY VOUCHER_DATE,TRANS_NO;
RECS S1%ROWTYPE;
--BEGIN QUERIES
BEGIN
DELETE FROM FIFO;
--OPENING BALANCES
INSERT INTO FIFO
VOUCHER_NO,VOUCHER_TYPE,VOUCHER_DATE,TRANS_QTY,TRANS_AMT,TRANS_RATE,
SHOLD_CODE,SHARE_TYPE,ACC_NO,SHARE_CODE,TRANS_NO)
SELECT TO_CHAR(FDATE1,'YYYYMM')||'001' VOUCHER_NO,'OP' VOUCHER_TYPE,
FDATE1-1 VOUCHER_DATE,
SUM(
CASE WHEN
--((SHARE_TYPE ='S' AND DTAG='Y')
SHARE_TYPE IN ('P','B','R','S') THEN
TRANS_QTY
ELSE
0
END
) TRANS_QTY,
SUM(TRANS_AMT),
NVL(CASE WHEN SUM(TRANS_AMT)<>0
AND
SUM
CASE WHEN SHARE_TYPE IN ('P','B','R','S') THEN
TRANS_QTY
ELSE
0
END
)<>0 THEN
SUM(TRANS_AMT)/
SUM
CASE WHEN SHARE_TYPE IN ('P','B','R','S') THEN
TRANS_QTY
ELSE
0
END
) END,0) TRANS_RATE,
MSHOLD_CODE SHOLD_CODE,'P' SHARE_TYPE,SHARE_ACCNO ACC_NO,
SHARE_CODE,0 TRANS_NO
FROM TRANS
WHERE ACC_NO=SHARE_ACCNO
AND SHOLD_CODE= MSHOLD_CODE
AND VOUCHER_DATE<FDATE1
--AND
--(SHARE_TYPE='S' AND DTAG='Y')
--OR SHARE_TYPE IN ('P','R','B'))
group by TO_CHAR(FDATE1,'YYYYMM')||'001', MSHOLD_CODE,SHARE_ACCNO, SHARE_CODE;
COMMIT;
--TRANSACTIONS BETWEEND DATES
INSERT INTO FIFO
TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
VOUCHER_DATE,TRANS_QTY,
TRANS_RATE,TRANS_AMT,SHOLD_CODE,SHARE_CODE,ACC_NO,
DTAG,TRANS_COST,SHARE_TYPE
SELECT TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
VOUCHER_DATE,TRANS_QTY,
CASE WHEN SHARE_TYPE='S' THEN
NVL(TRANS_RATE-COMM_PER_SHARE,0)
ELSE
NVL(TRANS_RATE+COMM_PER_SHARE,0)
END
,TRANS_AMT,SHOLD_CODE,SHARE_CODE,ACC_NO,
DTAG,NULL TRANS_COST,SHARE_TYPE
FROM TRANS
WHERE ACC_NO=SHARE_ACCNO
AND SHOLD_CODE= MSHOLD_CODE
AND VOUCHER_DATE BETWEEN FDATE1 AND FDATE2
AND
((SHARE_TYPE='S' AND DTAG='Y')
OR SHARE_TYPE IN ('P','R','B'));
COMMIT;
--PURCHASE CURSOR
IF P1%ISOPEN THEN
CLOSE P1;
END IF;
OPEN P1;
LOOP
FETCH P1 INTO RECP;
V_QTY:=RECP.TRANS_QTY;
V_RATE:=RECP.TRANS_RATE;
V_DATE:=RECP.VOUCHER_DATE;
dbms_output.put_line('V_RATE OPENING:'||V_RATE);
dbms_output.put_line('OP.QTY2:'||V_QTY);
EXIT WHEN P1%NOTFOUND;
--SALES CURSOR
IF S1%ISOPEN THEN
CLOSE S1;
END IF;
OPEN S1;
LOOP
FETCH S1 INTO RECS;
EXIT WHEN S1%NOTFOUND;
dbms_output.put_line('OP.QTY:'||V_QTY);
dbms_output.put_line('SOLD:'||RECS.TRANS_QTY);
dbms_output.put_line('TRANS_NO:'||RECS.TRANS_NO);
dbms_output.put_line('TRANS_NO:'||RECS.TRANS_NO);
IF ABS(RECS.TRANS_QTY)<=V_QTY
AND V_QTY<>0
AND RECS.TRANS_COST IS NULL THEN
--IF RECS.TRANS_COST IS NULL THEN
--dbms_output.put_line('SOLD:'||RECS.TRANS_QTY);
--dbms_output.put_line('BAL1:'||V_QTY);
UPDATE FIFO
SET TRANS_COST=V_RATE,
PUR_DATE=V_DATE
WHERE TRANS_NO=RECS.TRANS_NO
AND TRANS_COST IS NULL;
COMMIT;
dbms_output.put_line('UPDATE TRANS_NO:'||RECS.TRANS_NO);
dbms_output.put_line('OP.QTY:'||V_QTY);
dbms_output.put_line('SOLD:'||RECS.TRANS_QTY);
dbms_output.put_line('TRANS_NO:'||RECS.TRANS_NO);
dbms_output.put_line('BAL2:'||TO_CHAR(RECS.TRANS_QTY+V_QTY));
END IF;
IF ABS(RECS.TRANS_QTY)>ABS(V_QTY)
AND V_QTY<>0 AND RECS.TRANS_COST IS NULL THEN
UPDATE FIFO
SET
TRANS_QTY=-V_QTY,
TRANS_COST=V_RATE,
TRANS_AMT=ROUND(V_QTY*V_RATE,2),
PUR_DATE=V_DATE
WHERE TRANS_NO=RECS.TRANS_NO;
--AND TRANS_COST IS NULL;
COMMIT;
dbms_output.put_line('UPDATING 100000:'||TO_CHAR(V_QTY));
dbms_output.put_line('UPDATING 100000 TRANS_NO:'||TO_CHAR(RECS.TRANS_NO));
INSERT INTO FIFO
TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
VOUCHER_DATE,TRANS_QTY,
TRANS_RATE,TRANS_AMT,SHOLD_CODE,SHARE_CODE,ACC_NO,
DTAG,TRANS_COST,SHARE_TYPE,PUR_DATE
VALUES
MCL.NEXTVAL,RECS.VOUCHER_NO,RECS.VOUCHER_TYPE,
RECS.VOUCHER_DATE,RECS.TRANS_QTY+V_QTY,
RECS.TRANS_RATE,(RECS.TRANS_QTY+V_QTY)*RECS.TRANS_RATE,RECS.SHOLD_CODE,
RECS.SHARE_CODE,RECS.ACC_NO,
RECS.DTAG,NULL,'S',V_DATE
dbms_output.put_line('INSERTED RECS.QTY:'||TO_CHAR(RECS.TRANS_QTY));
dbms_output.put_line('INSERTED QTY:'||TO_CHAR(RECS.TRANS_QTY+V_QTY));
dbms_output.put_line('INSERTED V_QTY:'||TO_CHAR(V_QTY));
dbms_output.put_line('INSERTED RATE:'||TO_CHAR(V_RATE));
COMMIT;
V_QTY:=0;
V_RATE:=0;
EXIT;
END IF;
IF V_QTY>0 THEN
V_QTY:=V_QTY+RECS.TRANS_QTY;
ELSE
V_QTY:=0;
V_RATE:=0;
EXIT;
END IF;
--dbms_output.put_line('BAL3:'||V_QTY);
END LOOP;
V_QTY:=0;
V_RATE:=0;
END LOOP;
CLOSE S1;
CLOSE P1;
OPEN CV FOR
SELECT TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
VOUCHER_DATE,TRANS_QTY,
TRANS_RATE,TRANS_AMT,SHOLD_CODE,B.SHARE_CODE,B.ACC_NO,
DTAG,TRANS_COST,SHARE_TYPE, B.SHARE_NAME,A.PUR_DATE
FROM FIFO A, SHARES B
WHERE A.SHARE_CODE=B.SHARE_CODE
--AND A.SHARE_TYPE IS NOT NULL
ORDER BY VOUCHER_DATE,SHARE_TYPE,TRANS_NO;
END PROC_FIFO;
Thanks and Regards,
LuqmanCopy from TODOEXPERTOS.COM
Problem Description
When running a RAM build you get the following error as seen in the RAM build
log file:
14:52:50 2> Updating warehouse tables with build information...
Process Terminated In Error:
[Oracle][ODBC][Ora]ORA-01456: may not perform insert/delete/update operation inside a READ ONLY transaction
(SIGENG02) ([Oracle][ODBC][Ora]ORA-01456: may not perform insert/delete/update operation inside a READ ONLY transaction
) Please contact the administrator of your Oracle Express Server application.
Solution Description
Here are the following suggestions to try out:
1. You may want to use oci instead of odbc for your RAM build, provided you
are running an Oracle database. This is setup through the RAA (relational access
administrator) maintenance procedure.
Also make sure your tnsnames.ora file is setup correctly in either net80/admin
or network/admin directory, to point to the correct instance of Oracle.
2. Commit or rollback the current transaction, then retry running your
RAM build. Seems like one or more of your lookup or fact tables have a
read-only lock on them. This occurs if you modify or add some records to your
lookup or fact tables but forget to issue a commit or rollback. You need to do
this through SQL+.
3. You may need to check what permissions has been given to the relational user.
The error could be a permissions issue.
You must give 'connect' permission or roll to the RAM/relational user. You may
also try giving 'dba' and 'resource' priviliges/roll to this user as a test. Inorder to
keep it simple, make sure all your lookup, fact and wh_ tables are created on
a single new tablespace. Create a new user with the above privileges as the
owner of the tablespace, as well as the owner of the lookup, fact and wh_
tables, inorder to see if this is a permissions issue.
In this particular case, the problem was resolved by using oci instead of odbc,
as explained in suggestion# 1. -
ORA-01403 No Data Found error on Update
I am having difficulty troubleshooting a form (6i) where the data can not be updated. This form was recently modified by another developer (who is no longer w/ us) and we removed a unique key from the items list in the data block, however the particular field is still contained in the table. There are no constraints on any fields in this table.
I have a button pallette in the form and when I try to update and save, I get the "No Data Found" error message. However, I know there is data in the record but I can not figure out why the error.
When I display the error, the sql code looks something like this:
UPDATE db.temp
SET P_ID=:1,S_ID=:2
WHERE ROWID=:3
I put a message in the do_key('list_values') trigger to show me the rowid but nothing comes up. I wonder if this has something to do with that and if so, why and how do I fix it?
Appreciate any direction any of you can provide in coming to a solution on this. Thank you.I don't explicitly say ROWID=:3, what I mean, I
didn't code the update query. My understanding is
that it is done behind the scenes given the items in
the data block. Ok, I couldn't tell from the post whether it was explicit or not. This is from
Oracle FAQ:
"I get 'NO DATA FOUND' errors. How does one handle this?
An ORA-1403 (No Data Found) error is signalled within a replicated environment when there is a conflict in data. Here is an illustration of what happens in most scenarios featuring this error:
Let's say we need to update a table and set column x=1 where x=9. When the first change occurs on the source database, Oracle checks to ensure that x=9. Once this transaction commits, it is queued for execution on the destination site(s). When the transaction is applied to the destinations, Oracle first check to verify that x=9 (the old value); if it does, then Oracle applies the update (update table set x = 1 where x = 9); if it does not, an entry to the DEFERROR table is logged indicating ORA-1403.
If the application is updating primary key values, one can also expect plenty "NO DATA FOUND" errors. Primary keys should NEVER be updated. If one updates primary key values, conflict resolution also becomes extremely difficult. "
Check your pll file and anywhere else you are using db.temp. Then check the the update using PLSQL. -
ORA-47400: Command Rule violation for CONNECT on LOGON
Oracle : 11.2.0.2.0
OS : AIX
Issue : alter log throwing error
ORA-12012: error on auto execute of job "SYS"."IDX_RB$J_6640_2"
Errors in file /oradiag/diag/rdbms/p1edwni/p1edwni/trace/p1edwni_j000_8306748.trc:
ORA-12012: error on auto execute of job "SYS"."IDX_RB$J_6640_2"
ORA-47400: Command Rule violation for CONNECT on LOGON Fri May 13 03:31:30 2011 Errors in file /oradiag/diag/rdbms/p1edwni/p1edwni/trace/p1edwni_j002_7307362.trc:
ORA-12012: error on auto execute of job "SYS"."IDX_RB$J_6640_3"
Errors in file /oradiag/diag/rdbms/p1edwni/p1edwni/trace/p1edwni_j002_7307362.trc:
ORA-12012: error on auto execute of job "SYS"."IDX_RB$J_6640_3"
ORA-47400: Command Rule violation for CONNECT on LOGON
sacbidb02-prd{oracle}: cat /oradiag/diag/rdbms/p1edwni/p1edwni/trace/p1edwni_j002_7307362.trc
Trace file /oradiag/diag/rdbms/p1edwni/p1edwni/trace/p1edwni_j002_7307362.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
ORACLE_HOME = /oracle/product/11202_p1edwni/server
System name: AIX
Node name: sacbidb02-prd
Release: 1
Version: 6
Machine: 00C95CD24C00
Instance name: p1edwni
Redo thread mounted by this instance: 1
Oracle process number: 260
Unix process pid: 7307362, image: oracle@sacbidb02-prd (J002)
*** 2011-05-13 03:31:30.226
*** SESSION ID:(103.43457) 2011-05-13 03:31:30.226
*** CLIENT ID:() 2011-05-13 03:31:30.226
*** SERVICE NAME:(SYS$USERS) 2011-05-13 03:31:30.226
*** MODULE NAME:() 2011-05-13 03:31:30.226
*** ACTION NAME:() 2011-05-13 03:31:30.226
ORA-12012: error on auto execute of job "SYS"."IDX_RB$J_6640_3"
ORA-47400: Command Rule violation for CONNECT on LOGON
What could be the reason and how to resolve this ?
This appears coming form Database vault
Thanks in advanceHi:
I believe your question would be better targeted to the Database Vault forum, where you are more likely to get relevant responses. This is the Audit Vault forum, and people here would know less about that product than those on the other forum.
Regards. -
Reattempt of insert after a ORA-0001 unique constraint violation
Hi,
I'm inserting into a table. The primary key on this table is made up of the user id and a one-up transaction number. Unfortunately, I cannot change the design of this table.
Because I have to query the table to get the next transaction number before I insert into the table, I sometimes get a ORA-0001 (unique constraint violation) error because some other session grabbed the next transaction number and committed before I did.
To deal with this I retry the insert, that is, read the table again for the next tran number and insert. I allow for this up to 3 times. If after the third attempt I fail again, I rollback.
I'm seeing 3 records in the table.
So here are my questions: Do I need to rollback when I get the ORA-0001 error? I thought I wouldn't have to. If I do, why? The insert failed, how could the commit statement commit 3 records?
Thanks!No, the userid and transaction numbers are not the same (combined) for each of the 3 rows.
Here is the logic to retry again when I get a ORA-0001:
PROCEDURE insert_record(
table1_rec_in IN table1%ROWTYPE,
tran_number OUT table1.trans_number%TYPE,
attempt_number IN PLS_INTEGER)
IS
next_tran_number table1.trans_number%TYPE;
BEGIN
SELECT NVL(MAX(trans_number), 0) + 1
INTO next_tran_number
FROM table1
WHERE userid = table1_rec_in.table1_userid;
INSERT INTO table1
(userid,
trans_number,
amount,
transdate)
VALUES
(table1_rec_in.userid,
next_tran_number,
table1_rec_in.amount,
SYSDATE);
tran_number := next_tran_number;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
IF attempt_number < 3
THEN
DECLARE
next_attempt_number PLS_INTEGER;
BEGIN
next_attempt_number := attempt_number + 1;
insert_record(
table1_rec_in,
tran_number,
next_attempt_number);
END;
ELSE
RAISE unable_to_insert_rec;
END IF;
WHEN OTHERS THEN
RAISE unable_to_insert_rec;
END;
I'm using recursion to try the insert again. Is this the source of my problems? I don't see it and can't reproduce it. -
ORA-20001: Unable to create query and update page.
I am using the wizard: Form on a table with report 2 pages. I do not change any of the values when using the wizard (just taking all default values)
I created over 10 pages successfully already.
When creating the one page, I received this error on clicking the 'Finish' button
Error creating query and update.
Return to Application
ORA-20001: Unable to create query and update page. ORA-12899: value too large for column "FLOWS_010500"."WWV_FLOW_PAGE_PLUGS"."PLUG_QUERY_COL_ALLIGNMENTS" (actual: 269, maximum: 255)
Seems like it might be table related since I can continue and create more forms/reports on other tables.
Any help would be appreciated.336554,
Looks like there is a 127-column limit on the number of report columns supported when using that wizard. Do you have more than that?
57434 -
ORA-30027:Undo quota violation failed to get 92 (Bytes)
Hi All,
When running the accrual cutom report and it was taking long time and then it errors out.
Error is "ORA-30027:Undo quota violation failed to get 92 (Bytes)".
I asked Asked DBA to increase undo quota, or wait until other transactions to commit before proceeding
and DBA replied like "We have over 5GB of undo space--that's a huge amount for a single report to use".
Please let me know, any idea how to fix this issue?
Thanks,
Prasad RajuHi,
Please see these documents.
Note: 173698.1 - OERR: ORA-30027 Undo quota violation - failed to get %s (bytes)
https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=173698.1
Note: 559624.1 - What Does Undo Quota Mean And How Can We Solve ORA-30027
https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=559624.1
Regards,
Hussein -
ORA-00001 unique constraint violation updating row
Hi Folks,
Using oracle application express version 3.1.2.00.02 to update one column in a table ORA-00001: unique constaint (BI_ADS.FCV_UK) violated error is returned. This is strange as the column being updated has no constraint on it.
We have had a trace done on the database action and it is a normal UPDATE statement.
You can run this UPDATE statement directly against the database with no errors.
When using APEX the error is returned.
Some rows update OK and a few rows will not.
There are no sequences involved.
Thanks
BrianIt turns out the form is stripping the time off the date column (constraint column) and this is causing the unique contraint violation. Any one had any dealings with times not being updated with a date column from a form??
-
Checking NULL in multi column Update
I have a Update query that updates 2 columns based on the value from other table. Now there may not be a corresponding record in 2nd table and so my first table can be updated with NULL. Now how do i perform a NVL check for this
Query
Update Table1
Set (col2,col3) =
( select col2, col3
from table2
where table2.col1 = table1.col1)
At present i have to repeat the entire condition in SET clause into where clause to avoid this. Is there any better way ?Eric:
The restriction is that each row in table1 must match with only one row in table2 (or none in which case it will be eliminated from the join and, therefore, not updated). Many rows in table1 can match with a single row in table2.
SQL> CREATE TABLE t (id NUMBER, descr VARCHAR2(10));
Table created.
SQL> INSERT INTO t VALUES (1, 'One');
1 row created.
SQL> INSERT INTO t VALUES (1, 'Un');
1 row created.
SQL> INSERT INTO t VALUES (2, 'Two');
1 row created.
SQL> COMMIT;
Commit complete.
SQL> CREATE TABLE t1 (id NUMBER, descr VARCHAR2(10));
Table created.
SQL> ALTER TABLE t1 ADD CONSTRAINT t1_pk PRIMARY KEY (id);
Table altered.
SQL> INSERT INTO t1 VALUES(1, 'Uno');
1 row created.
SQL> INSERT INTO t1 VALUES (3, 'Tres');
1 row created.
SQL> COMMIT;
Commit complete.
SQL> UPDATE (SELECT t.id, t.descr, t1.descr t1descr
2 FROM t, t1
3 WHERE t.id = t1.id)
4 SET descr = t1descr;
2 rows updated.
SQL> SELECT * FROM t;
ID DESCR
1 Uno
1 Uno
2 TwoThe uniqueness of table2 must be declared, it is not determined at runtime,
SQL> ROLLBACK;
Rollback complete.
SQL> ALTER TABLE t1 DROP CONSTRAINT t1_pk;
Table altered.
SQL> UPDATE (SELECT t.id, t.descr, t1.descr t1descr
2 FROM t, t1
3 WHERE t.id = t1.id)
4 SET descr = t1descr;
SET descr = t1descr
ERROR at line 4:
ORA-01779: cannot modify a column which maps to a non key-preserved tableJohn -
Unique Key Violation error while updating table
Hi All,
I am having problem with UNIQUE CONSTRAINT. I am trying to update a table and getting the violation error. Here is the over view. We have a table called ActivityAttendee. ActivityAttendee has the following columns. The problem to debug is this table has
over 23 million records. How can I catch where my query is going wrong?
ActivityAttendeeID INT PRIMARY KEY IDENTITY(1,1)
,ActivityID INT NOT NULL (Foreign key to parent table Activity)
,AtendeeTypeCodeID INT NOT NULL
,ObjectID INT NOT NULL
,EmailAddress VARCHAR(255) NULL
UNIQUE KEY is on ActivityID,AtendeeTypeCodeID,ObjectID,EmailAddress
We have a requirement where we need to update the ObjectID. There is a new mapping where I dump that into a temp table #tempActivityMapping (intObjectID INT NOT NULL, intNewObjectID INT NULL)
The problem is ActivityAttendee table might already have the new ObjectID and the unique combination.
For example: ActivityAttendee Table have the following rows
1,1,1,1,NULL
2,1,1,2,NULL
3,1,1,4,'abc'
AND the temp table has 2,1
So essentially when I update in this scenario, It should ignore the second row because, if I try updating that there will be a violation of key as the first record has the exact value. When I ran my query on test data it worked fine. But for 23 million records,
its going wrong some where and I am unable to debug that. Here is my query
UPDATE AA
SET AA.ObjectID = TMP.NewObjectID
FROM dbo.ActivityAttendee AA
INNER JOIN #tmpActivityMapping TMP ON AA.ObjectID = TMP.ObjectID
WHERE TMP.NewObjectID IS NOT NULL
AND NOT EXISTS(SELECT 1
FROM dbo.ActivityAttendee AA1
WHERE AA1.ActivityID = AA.ActivityID
AND AA1.AttendeeTypeCodeID = AA.AttendeeTypeCodeID
AND AA1.ObjectID = TMP.NewObjectID
AND ISNULL(AA1.EmailAddress,'') = ISNULL(AA.EmailAddress,'')>> I am having problem with UNIQUE CONSTRAINT. I am trying to update a table and getting the violation error. Here is the over view. We have a table called Activity_Attendee. <<
Your problem is schema design. Singular table names tell us there is only one of them the set. Activities are one kind of entity; Attendees are a totally different kind of entity; Attendees are a totally different kind of entity. Where are those tables? Then
they can have a relationship which will be a third table with REFERENCES to the other two.
Your table is total garbage. Think about how absurd “attendee_type_code_id” is. You have never read a single thing about data modeling. An attribute can be “attendee_type”, “attendee_code” or “attendee_id”but not that horrible mess. I have used something like
this in one of my busk to demonstrate the wrong way to do RDBMS as a joke, but you did it for real. The postfix is called an attribute property in ISO-11179 standards.
You also do not know that RDBMS is not OO. We have keys and not OIDs; but bad programmers use the IDENTITY table property (NOT a column!), By definition, it cannot be a key; let me say that again, by definition.
>> ActivityAttendee has the following columns. The problem to debug is this table has over 23 million records [sic: rows are not records]<<
Where did you get “UNIQUE KEY” as syntax in SQL?? What math are you doing the attendee_id? That is the only reason to make it INTEGER. I will guess that you meant attendee_type and have not taken the time to create an abbreviation encoding it.
The term “patent/child” table is wrong! That was network databases, not RDBMS. We have referenced and referencing table. Totally different concept!
CREATE TABLE Attendees
(attendee_id CHAR(10) NOT NULL PRIMARY KEY,
attendee_type INTEGER NOT NULL --- bad design.
CHECK (attendee_type BETWEEN ?? AND ??),
email_address VARCHAR(255),
CREATE TABLE Activities
(activity_id CHAR(10) NOT NULL PRIMARY KEY,
Now the relationship table. I have to make a guess about the cardinally be 1:1, 1:m or n:m.
CREATE TABLE Attendance_Roster
(attendee_id CHAR(10) NOT NULL --- UNIQUE??
REFERENCES Attendees (attendee_id),
activity_id Activities CHAR(10) NOT NULL ---UNIQUE??
REFERENCES Activities (activity_id)
PRIMARY KEY (attendee_id, activity_id), --- wild guess!
>> UNIQUE KEY is on activity_id, attendee_type_code_id_value_category, object_id, email_address <<
Aside from the incorrect “UNIQUE KEY” syntax, think about having things like an email_address in a key. This is what we SQL people call a non-key attribute.
>> We have a requirement where we need to update the ObjectID. There is a new mapping where I dump that into a temp table #tempActivityMapping (intObjectID INTEGER NOT NULL, intNewObjectID INTEGER NULL) <<
Mapping?? We do not have that concept in RDBMS. Also putting meta data prefixes like “int_” is called a “tibble” and we SQL people laugh (or cry) when we see it.
Then you have old proprietary Sybase UODATE .. FROM .. syntax. Google it; it is flawed and will fail.
Please stop programming until you have a basic understanding of RDBMS versus OO and traditional file systems. Look at my credits; when I tell you, I think I have some authority.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
ORA-01403: No data found (Occured in UPDATE Statement)
Dear All,
I am getting No data found error while executing the following UPDATE statement.
UPDATE DEAL
SET CLIENT_CD = 'HDMJARVN'
WHERE CA_REF_NO = 70728
AND CLIENT_CD = 'HDMJARVI';
Wheareas
SELECT *
FROM DEAL
WHERE CA_REF_NO = 70728
AND CLIENT_CD = 'HDMJARVI';
Gives me 1 row.
Please explain.....
Thanks in Advance.UPDATE DEAL
t line 1:
ORA-01403: no data foundHi Yogesh,
I created a trigger on a table "CHILD" which fires during UPDATE statement. As you may notice, the trigger raises "no data found" exception which is not handled as a result the update ends up with an error.
Similar is your case, investigate the trigger to resolve the issue.
SQL> desc child
Name Null? Type
B NUMBER
SQL> create or replace trigger child_trig
2 after update of b on child
3 referencing old as old new as new
4 for each row
5 declare
6 l_dummy number;
7 begin
8 select 1 into l_dummy from dual where dummy = 'TEST';
9 end;
10 /
Trigger created.
SQL> select * from child;
B
1
SQL> update child set b = 5;
update child set b = 5
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "TEST.CHILD_TRIG", line 4
ORA-04088: error during execution of trigger 'TEST.CHILD_TRIG'
SQL>Regards
Maybe you are looking for
-
Help with Exporting to Youtube
I'm a high school math teacher, and I began using PCP2 in January to screencast my lessons. As I prepare for next year, I want to begin exporting automatically to YouTube. Marcel Borsten graciously wrote a script (posted at http://podcastproducer.org
-
How to use Process_type in Transaction Launcher Wizard?
We have a number of Process_types already setup in the CRMC_PROC_TYPE table. These were setup for use by the Winclient IC Action boxes to display transactions. With the Action boxes being the forerunner to the Transaction Launcher. We now need to put
-
HP 400-214 How do Audio sound for 1 : 5
It worked well on a 2 yr old Dell desktop No luck figuring this out . Help Wanted.
-
Installing Boot Camp Update 3.3
Hi. Currently, I've installed Boot Camp 3.0 on Windows 7 (32-bit) with my Snow Leopard installation disk. Would it be possible to upgrade straight to Boot Camp 3.3, or do I need to install updates 3.1 and 3.2 first? Thanks.
-
How to make html file from a text field data
hi! I want to know how to make a file with .html extension and the data in this file should be from a text field. like i want to enter some thing in a text area and have to place it in a file on server side in html formate.