SQL & PL/SQL :: Update Cascade

May 28, 2010

do we have ON_UPDATE_CASCADE? or there is no ON_UPDATE_CASCADE is oracle and we have just ON_DELETE_CASCADE

View 1 Replies


ADVERTISEMENT

On Delete Cascade

Mar 27, 2007

We have a bunch of tables with FKs but we do not have the 'on delete cascade' option on these FKs. If I want to delete records in the database do I have to write delete statements for each table starting with the lowest child or is there a cascade option I can use with the delete statement?

View 1 Replies View Related

PL/SQL :: On Delete Cascade?

Oct 27, 2013

, we have used alter table to change the constraint in on delete cascade. there is two option. what is different between both ofthem. Example:1)Alter table t3 add constraint t2_F foreign key (id) references t2(id,column2,column3) on delete cascade ;or2)Alter table t3 add constraint t2_F foreign key (id) references t2 on delete cascade ; 

know first one that particular column will set to on delete cascade.What is the use of second one in this case we are not using column name in "foreign key (id) references t2 on delete cascade ;" 

View 9 Replies View Related

SQL & PL/SQL :: Constraints And Delete Cascade Events

May 9, 2011

I have a table with 2 defined FK constraints which fires delete cascade events.

I want to deny deletions when the event is fired from one of the tables and permit them when the event is fired from the other table.

Is it possible?

Is any way to solve which table fires the event?

View 2 Replies View Related

Gathering Statistics With Cascade Option Is Slow

Oct 9, 2012

The database is 11.2.0.3 on a linux machine. I issued the following command, but the session was a little slow. The table size is about 50 GB and has 3 indexes. I specified "degree=8" for parallel processing.

When gathering statistics on the table , parallel slaves were invoked and gathering statistics on the table has finished fast enough. However, when it goes to gathering statistics on the indexes, only one active session was invoked, and thus "degree=8" option was ignored.

My question is :

Do I need to use dbms_stats.gahter_index_stats instead of "cascade" option in order to gather statistic on the indexes with parallelism?

exec dbms_stats.gather_table_stats(ownname=>'SDPSTGOUT',tabname=>'OUT_SDP_CONTACT_HIS',estimate_percent=>10, degree=>8 , method_opt=>'FOR ALL COLUMNS SIZE 1',Granularity=>'ALL',cascade=>TRUE)

View 2 Replies View Related

PL/SQL :: To Delete Child Records Manually Without Using Oracle Delete Cascade

Oct 9, 2012

I have to write a procedure that accepts schema name, table name and column value as parameters....I knew that i need to use metadata to do that deleting manually.

View 9 Replies View Related

Forms :: Insert And Update Directly Into Table From Pre Update Trigger Of Block?

May 14, 2010

I have a base table (Table A) block with multiple records displayed. I need to track audits to this underlying table in the following way:

If user updates a field in the block I want the pre-changed record's audit fields to be set and I need to create a copy of the record with the changed values. Basically any changes will result in the record being logically deleted, and a copy record created with the newly changed values.

Tried to implement in the block's pre-update trigger which will call a package to directly update Table A then Insert into Table A, then requery the block. Is there a clean and efficient way to do this?

View 4 Replies View Related

Update Statement Versus Cursor Based Update

Sep 7, 2010

I have to update 20 and 60 million records of a table. The update statement are

1> 20 million recs
update mycustomer set update_time=add_months(sysdate,240) where seq_num = 1;

commit;

2> 60 million recs
update mycustomer set update_time=sysdate-seq_num where seq_num <> 1;

commit;

Q1> Is there any way to improve performance
Q2> Will parallel dml improve performance
Q2> Would a pl/sql cursor make any difference in speed.

View 1 Replies View Related

SQL & PL/SQL :: Update Statement With Join Only Update Matching Rows

Aug 17, 2010

This is my query:

UPDATE t_tt_hours a
SET a.sak_request = (
SELECT b.sak_request
FROM t_requests b, co c

[Code]...

The problem I am having is that it is updating all rows even when it is pulling back a null value for b.sak_request. I've tried adding b.sak_request is not null to the select statement like this:

UPDATE t_tt_hours a
SET a.sak_request = (
SELECT b.sak_request
FROM t_requests b, co c
WHERE b.nam_eds_tracking_id = c.id_dir_track_eds

[Code]...

but it doesn't seem to make a difference. The reason I need to do this is that the difference between where it matches with a valid (non-null) value is 396 rows vs. 12,484 rows which is too time consuming to run on my page.

View 9 Replies View Related

SQL & PL/SQL :: Create Trigger That Will Update Table When There Is Insert / Update

May 29, 2012

i want to create a trigger that will update a table when there is an insert or update.i can't across this error that i don't even know what it means "table %s.%s is mutating, trigger/function may not see it".

*Cause: A trigger (or a user defined plsql function that is referenced in this statement) attempted to look at (or modify) a table that was in the middle of being modified by the statement which fired it.

*Action: Rewrite the trigger (or function) so it does not read that table.

CREATE OR REPLACE TRIGGER set_date_end
BEFORE INSERT OR UPDATE OF issued ON shares_amount
FOR EACH ROW
DECLARE
BEGIN
INSERT INTO shares_amount(date_end) VALUES(SYSDATE);
END set_date_end;
/

View 3 Replies View Related

SQL & PL/SQL :: Update Previous Row Based On Next Row And Update Duplicate Record

Mar 6, 2013

create table test1

( ID NUMBER(11)
,MEMBER_NMBR NUMBER(10)
,CODE_NMBR NUMBER(7)
,ROW_EFCTV_DT DATE
,ROW_TRMNTN_DT DATE

[code]....

insert into test1 values (11007,7462,32,'30/sep/2012','31/dec/9999',3,'25/sep/1998','AUTUMN',1,0,344);
insert into test1 values (11007,7462,32,'30/oct/2012','31/dec/9999',3,'25/sep/1998','AUTUMN',1,0,344);
IDMEMBER_NMBRCODE_NMBRROW_EFCTV_DTROW_TRMNTN_DTFLAG_NMBRBRTH_DTNAMECLAIM_CDAMT1AMT2
1100774623209/30/2012 00:0012/31/9999 00:00309/25/1998 00:00AUTUMN10344
1100774623210/30/2012 00:0012/31/9999 00:00309/25/1998 00:00AUTUMN10344

I have to update the row_trmntn_dt of first row to row_efctv_dt of 2nd row which is 30th Oct 2012 - 1 day i.e. 29th Oct 2012

View 10 Replies View Related

PL/SQL :: Update Multiple Columns With Single Update Statement

May 30, 2013

i am reading the columns value from different table but i want to update it with single update statement. such as how to update multiple columns (50 columns) of table with single update statement .. is there any sql statement available i know it how to do with pl/sql.

View 5 Replies View Related

SQL & PL/SQL :: How To Update Multiple Rows With Different Values Using Update Statement

Mar 21, 2011

I have one doubt about update command in sql. How to update the multiple rows with different values using update statment.

Eg:-

SQL> set linesize 500;
SQL> set pagesize 500;
SQL> select * from emp;
SQL> select empno,ename,sal from emp;
SQL> select empno,ename,sal from emp;

EMPNO ENAME SAL
---------- ---------- ----------
7839 KING 5000
7698 BLAKE 2850
7782 CLARK 2450
7566 JONES 2975
7654 MARTIN 1250

[Code]....

The above table contains 14 records. Now i would like to update the salary column with different values like

EMPNO SAL
===========
7839 18000
7698 20000
7782 5000
...
...
...
7934 25000

How to update above values with single update query.

View 11 Replies View Related

SQL & PL/SQL :: Compound Trigger Update Firing Update

Jan 25, 2012

After many tests I can't make work and update of the same table inside the same table.

Trying to avoid Mutating Table Error now I have
ORA-00036: maximum number of recursive SQL levels (50) exceeded

Sample Data :

create table test_compound (USERID VARCHAR2(10),APP VARCHAR2(15),LAST_UPDATED_ON TIMESTAMP);

insert into test_compound values ('user1','1',systimestamp);
insert into test_compound values ('user2','2',systimestamp-4);
insert into test_compound values ('user3','3',systimestamp-6);

CREATE OR REPLACE TRIGGER trigger_test
FOR UPDATE ON test_compound
COMPOUND TRIGGER
TYPE t_tab IS TABLE OF VARCHAR2(50);
l_tab t_tab := t_tab();
[code].......

When I execute :

update test_compound
set last_updated_on=systimestamp
where userid='user1' and app='1';

The trigger should update the first row and all the data from test_compound table where userid='user1'. Maybe the problem is that updating the same table inside the trigger is firing in a recursive way the trigger.

View 13 Replies View Related

SQL & PL/SQL :: How To Update Multiple Table With Single UPDATE

Jul 19, 2011

I have a column "empno" in EMP table and "deptno" in DEPT table . I want to update both the columns with single UPDATE statement. With out a creation of stored procedure or view(updating it through view).

View 4 Replies View Related

SQL & PL/SQL :: Create Trigger To Update Table B After Update On Table A

Jul 21, 2011

I have table test1(id,name) and table test2(id,,name)

Now when I update name column of a row on test1 I want the same value to be updated for the same id in test2.

So I wrote this trigger but its not working

create trigger test_trigger after update on test1 for each row
begin
update test2 set name=new.name where test2.id=id
end
/

View 9 Replies View Related

Where Current Of - For Update Of

Oct 5, 2010

I have an employee table that has a paygrp_id that will be used for my subset of employees. For all the employees that have the paygrp_id = 10212 on the employee table I need to update the workbrain_user table to set the flag wbu_cansee_self to 'N'. The join between the employee table and the workbrain_user table is the emp_id.I get the following error when I run this cursor.

[error]
Error on line 0
DECLARE
CURSOR wbuFlag_cur
IS SELECT e.emp_fullname, e.paygrp_id,wbu.WBU_CANS
[code]...

View 3 Replies View Related

SQL & PL/SQL :: Update Returns More Than One Row?

Oct 26, 2010

I have to update a table by getting values from two other tables. While doing that the inner query returns more than one value. I am not sure how to implement the logic without returning more than one row in sub query.

My query:
update buf_office_str o
set o.manager_ident =
(select sp.ident
from se2_r_src_sourceperson sp ,
(select distinct director_name, team_name from buf_sales_dump )t
where SP.SRCNAME = upper(substr(t.director_name,instr(t.director_name,' ')+1,length(t.director_name))||', '||substr(t.director_name,1,instr(t.director_name,' ')-1 ) )
and o.office_descr = t.team_name
)

Basically the query gets the manager id from sp table where sp.srcname = t.team-name.
The office_descr should be equal to the team_name.

This is the logic I am working towards:

For each office, i get the office_descr and get corresponding team_name. Match the team's director_name (from table t) with the sp.name and return the employee's id (sp.ident) for that office_descr. I need to update all 50 offices with corresponding managerid for that office in buf_office_str table.

Is it possible to get done in one update? Or, does this need a plsql proc to do this logic.

View 3 Replies View Related

SQL & PL/SQL :: How To Update Clob Value

Nov 13, 2012

I the table VOYAGERS with the following data.

ID is of type number and DETAILS is of type CLOB.

ID DETAILS
--- --------
100 The ship has left san diego http:/localhost/icons/sandiego.png to okinawa on nov 10, 2011.

I need to update the record(id = 100) by replacing the url "http:/localhost/icons/sandiego.png" with "http:/localhost/icons/okinawa.png".

I need a procedure where I will pass the ID value, replace string(i.e http:/localhost/icons/sandiego.png) and replace with string (ie. http:/localhost/icons/okinawa.png).

View 2 Replies View Related

SQL & PL/SQL :: Returning Old Value During Update?

Jan 2, 2012

In a pl/sql procedure, when I am doing an update, I need the old value to be returned and stored in a local variable, so that the same can be used for future purpose.

Note : I know the "OLD:" option is present when we use TRIGGER, but in my case , the table I am updating is a old table and I am not permitted to create a trigger for it.

View 9 Replies View Related

SQL & PL/SQL :: Update From Other Table Value?

Oct 26, 2010

I am having a requirement to update a table column from min value of column from other table..

Since i cannot format the code well here..I attaching one pdf where we have details and requirements..

View 7 Replies View Related

SQL & PL/SQL :: Update Every Tow Trigger?

Apr 27, 2011

I have one table with one row with some coefficients. If I update a coefficient from my table I want to be updated all the rows from another table. I've made a trigger but in the second table I have a column for example TOTAL and I want that column to be multiplied with my new coefficient, and I want this for every row in the second table. How I can select that total column in the trigger for every single row and update it?

View 14 Replies View Related

SQL & PL/SQL :: Using Update With A Join?

Mar 16, 2011

im trying to update a column in the employee table with the value "YES". Im getting an error message saying im missing a SET statement from this code below:

update e
SET e.review='YES'
from employee
inner join rentals r
on e.employee_id=r.employee_id
inner join job j
on e.job_id=j.job_id
where r.plate ='FY06WNT'
and j.function !='MANAGER'
and j.function !='PRESIDENT';

View 2 Replies View Related

SQL & PL/SQL :: How To Update With Join

Jul 7, 2010

drop table dev10 purge
/
drop table dev11 purge
/
drop table dev12 purge
/
create table dev10 as
select rownum c1, sys.dbms_random.string('U', 6) c2, trunc(sys.dbms_random.value(1, 7)) c3
from dual connect by rownum < 8
/

[Code]...

Now, Let us assume that, the record is

AAAAAA BBBBBB CCCCCC
DDDDDD EEEEEE FFFFFF
...
..
.

Now, we want dev12.c2 is 'FFFFFF' if dev11.c2 is 'BBBBBB', if we want to get this:

AAAAAA BBBBBB FFFFFF
DDDDDD EEEEEE FFFFFF
...
..
.

We can make this for SqlServer by coding:

UPDATE dev10
SET c3 = dev12.c1 FROM dev10 INNER JOIN dev11 ON dev11.c3 = dev10.c1 CROSS JOIN dev12
WHERE (dev11.c2 LIKE 'BBBBBB')
AND (dev12.c2 LIKE 'FFFFFF')
/
but, Oracle, what should we do new?

View 11 Replies View Related

Forms :: Old Value On Update

Aug 16, 2010

i have two forms one releaseorder (master/detail) and second stock query (single table)

when the user enter the detail table like container no one or more rows then it will insert the rows into stock table through post insert but if need to change the multiple container no then it will only update the one container no where cursor available through post update how to update multiple container no in stock table should i try copy container value to display item or :global.old value.

View 1 Replies View Related

SQL & PL/SQL :: Update All Rows At Once

Aug 28, 2011

I want to update salary column of emp table in a way that every value of salary column be increased by 1000, is this possible I can do this one statement only??

(Just FYI-

SQL> desc emp;
Name Null? Type
----------------------------------------- -------- ----------------------------

EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)

)

[Code].....

View 2 Replies View Related

Update Where Current Of

Sep 27, 2010

I have a table I need to update called employee_history. It has almost the exact same values as another table called Employee. The difference being that the employee_history has a start date and end date. So it allows you to have overrides in the future. The employee table is static. So it only allows you to see the current data as of today.

I need to write an insert statement that will pull values from employee table and populate the employee_history table but I also have columns in the employee_history table that requires a next value and a start and end date.

From the employee table I want to select e.emp_id, e.emp_firstname, e.emp_lastname, e.shftpat_id, e.client_id from employee e

I want to INSERT INTO EMPLOYEE_HISTORY (EMHIST_ID, EMPHIST_START_DATE, EMPHIST_END_DATE, EMP_ID, EMP_FIRSTNAME, EMP_LASTNAME, SHFTPAT_ID, CLIENT_ID)

with the VALUES being (SEQ_EMPHIST_ID.nextval, TRUNC(sysdate), 01/01/3000 and the employee data from the employee table)). I bought the book Easy Oracle PL/SQL Programming but I am not finding what I need. It gives an example of a CURSOR FOR UPDATE and a reference to an UPDATE WHERE CURRENT OF.

The examples are straight forward where you take two columns from table one and update a new table with those values, or where you select a subset of employees that need a commission and update the emp table with that commission.

View 1 Replies View Related

SQL & PL/SQL :: Trigger After Update

Jun 4, 2012

How to make a trigger of changing value. For example I have a table of customer .

Customer_id, Cumtomer_name, cus_date and stats.
Values
102, ABC,02-06-2012 and Open

Now tell me how I can make trigger after two hours stats change OPEN TO CLOSE.

View 26 Replies View Related

Update With Join

Apr 13, 2011

This is my working query in ms access...

UPDATE Caxnode AS A INNER JOIN Caxnode AS B ON A.node_alias = B.node_alias SET A.partition_Type = 'LDOM', A.node_mode = 'LOGICAL', A.host_id = b.host_id, A.num_of_proc = b.num_of_proc WHERE (((A.node_mode)='virtual' Or (A.node_mode)='regular') AND ((B.partition_Type)='LDOM'));

This doesn't work in oracle, I googled and read that update doesnt work with inner join in oracle..

translate this query to work on oracle?

View 5 Replies View Related

SQL & PL/SQL :: Update Is Not Working

Apr 27, 2012

with a as (
SELECT subscriber_agn,max(ixml_id) ixml_id, claim_id
FROM
(

[Code].....

i want to combine above two and need only one sql stmt.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved