Create ViewCriteria comparing two columns from same table
Does anyone know how I can create a ViewCriteria where clause that compares two columns from the same table?
For example if I had two integer columns (MINSAL and MAXSAL) and wanted to see if they are equal. I would normally do the following SQL below.
SELECT * FROM EMPL
WHERE MINSAL = MAXSAL
It works, but it is not ideal.
Setup a Transient column that performs a groovy evaluation of MINSAL=MAXSAL and then my ViewCriteria evaluates the column to true and I set Query Execution Mode to Both.
Similar Messages
-
Select column 1 into two column from same table
Dear Sir
I have a data like
studid makr tottal credit total average mark semester
251; 249.84; 41; 6.09; 1
106; 285.32; 42; 6.79; 1
285; 263.88; 38; 6.94; 1
251; 202.40; 28; 7.23; 2
106; 293.20; 39; 7.52; 2
285; 228.14; 39; 5.85; 2
I want to select average mark semester1 and semester 2 in different column
studid average_mark_ semester1 average_ mark_ semester_ 2
251 6.09 7.23
106 6.79 7.52
285 6.94 5.85
please help me
regards
sanat kumar
thanks in advanceDear Sir,
Thank u for your prompt answer.
But I want to select student id and average mark based on semester
out put supposed to be
student id average_makr_sem1 average_mark_sem2
251 6.09 7.23
106 6.79 7.52
285 6.94 5.85
I want to select the average mark in different column based on semester
Please look into
thanks
regards
sanat -
Problem creating a datablock with columns from 2 tables...
Hello guys, i have a problem in creating a datablock with columns from 2 different tables. I try to create the datalock manually and in the Query Data Source Type Property i choose FROM clause query, and in the query data source name property i type my sql statement with the columns i want to display.After that i place the items that the datablock will contain , manually from the painter. However , when i run the application, the datablock doesn't display the items from the database. Am i doing something wrong?
Thanx in advance,
Regards,
Bill.Never mind Peter, I found the error. I forgot to make execute_query for the datablock, so this was the reason why the items weren't displayed to me.
Thanx anyway a lot for your advices and your time you spent ! -
Compare two rows in same table
Hi,
I want to compare two rows (some columns) in the same table, and if the data in the data columns is different, I want to pick the latest one. The table is date tracked. For instance I have an address table with different addresses for an employee with effective date. I want to be able to pick the latest row if the postal code is different for the 2 rows. Is this possible in sql. I can do this in Pl/sql, but dont want to use it. Eg
address_id, postal_code, person_id,last_update_date
123, pn123,1,12-JAN-01
124,pu124,1,13-JAN-01
I want to be able to retrieve just the second line.
Any help is appreciatedWelcome to the forum!
Whenever you post please provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
>
The table is date tracked. For instance I have an address table with different addresses for an employee with effective date. I want to be able to pick the latest row if the postal code is different for the 2 rows.
>
Your question is a little confusing because you are using terms like 'date tracked' and 'effective date' without explaining exactly what your definitions of those terms is.
Why do you want the latest record ONLY if the postal code is different? What if the address is different? Then which record do you want?
Why not just take the record for each person/company that has the latest date? If the data is the same then it doesn't which record you get so the one with the latest date will do. And if the data is different taking the one with the latest date gives you the latest data.
The classic definition of effective date is 'the date the information becomes effective'. Information with a given effective date is NOT in effect before that date and is SUPERCEDED when data is entered with a later effective date if the actual date is later than or equal to the effective date. Using your data
>
123, pn123,1,12-JAN-01
124,pu124,1,13-JAN-01
>
The first record IS NOT effective for dates prior to 12-JAN-01. In fact for a query looking for data prior to that date there isn't any data.
The first record is also NOT effective for dates on or after 13-JAN-01. Only the second record is effective.
If you added a record for 14-JAN-01 this record would not be effective until on or after that date (i.e. not for another 4 1/2 months).
So for the classic definition of effective date the query needs to provide the AS OF date to use to obtain the data. If, as in your system, you are not allowed to create records with dates in the future and you just want the latest record then you can just select the record with the MAX(myDate) value for the given person_id, address_id or whatever your key values are.
Edited by: rp0428 on Aug 11, 2012 7:50 AM -
Comparing two records from different tables error.
Hi folks!
I have this PL/SQL Block.
I want to compare the only one record from both tables to see if the content of them are equal or not, but I don't want to specified column by column to do that.
Any idea?
Thanks a lot in advanced,
Abdel E. Miranda S.
Panama
declare
cursor c_aems_prueba is
select nombre, direccion, telefono, limite, seq
from aems_prueba;
cursor c_aems_testing is
select nombre, direccion, telefono, limite, seq
from aems_testing;
vc_aems_prueba c_aems_prueba%rowtype;
vc_aems_testing c_aems_testing%rowtype;
vt_aems_prueba aems_prueba%rowtype;
vt_aems_testing aems_testing%rowtype;
begin
insert into aems_prueba
values('ABDEL MIRANDA', 'PAITILLA', '215-3411', 1000, 1);
insert into aems_testing
values('ABDEL MIRANDA', 'PAITILLA', '215-3411', 1000, 1);
commit;
open c_aems_prueba;
fetch c_aems_prueba into vt_aems_prueba;
open c_aems_prueba;
fetch c_aems_prueba into vt_aems_testing;
if vt_aems_prueba = vt_aems_prueba
then
dbms_output.put_line('son iguales las variables, si funciona la comparacion de dos estructuras');
else
dbms_output.put_line('no son iguales las variables, no funciona la comparacion de dos estructuras');
end if;
close c_aems_prueba;
close c_aems_testing;
end;Satyaki De,
Java is involving because an Outsourcing new project. The outsourcing company is developing the new application using JSF which invoke an interface java method [depending of the operation: select, update, insert] and them invoke the PLSQL API to precess tha operation.
In the case I already wrote here, the issue is this:
The user search for a specific data using the interface. The java method send a request for these operation through the API. the PLSQL process the request and return a beam, with all the column the user look for.
The user see the information in the application windows. Assuming the user wants to change some data, he modify just one field [lets say telephone number] and press the update button. The application process the request using a different method, which invoke a different function within the PLSQL API.
Once the information is returning to the API, I must know if at least one field change its value. So I was thinking to get the beam with the data before it was changed and compare it with the beam with the changing data.
If current_beam = new_beam
then
update
else
no change to process
end if;
Any idea. -
Question about suming two columns from different tables in Subquery?
Hello everyone,
I have a subquery that works great for getting the total SUM of a Billing table, but I also need to add to that SUM the total surcharges or additional charges from a separate table. I tried this by doing something like so:
(SELECT SUM(SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No', SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill')) as [Amount],
But it doesn't work as there is an incorrect syntax near 'FROM'. I'm assuming this is because of the two FROM's in the Subquery? But I am not sure how else I would be able to do this then?
Any help would be greatly appreciated. I just noticed this bug and am hoping to get a fix out as quickly as possible.
Thanks Again,Hi, sorry for taking so long to get back to this post.
I tried this example like so:
(SELECT SUM(A1) AS Total1, SUM(A2) AS Total2
FROM
(SELECT
(SELECT SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No') AS A1,
(SELECT SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill') AS A2),
However, get an error that an Incorrect Syntax exists near the ','. I remove the comma (Which I think should be there), and I get an error that an Incorrect Syntax exists near the '.'...
I also tried doing it like this (Based on other suggestions I've found online:
(SELECT SUM(SELECT SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No') as [Amount],
(SELECT SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill') as [Additional]),
And I get an error that an Incorrect Syntax exists near 'SELECT'...
I also tried doing something like this with the SQL I already had...
(SELECT SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No') as [BilledAmount],
(SELECT SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill') as [Additional],
SUM(BilledAmount + Additional) AS [TotalBilled],
But I get an error that the alias' are Invalid Column Names... I have used Alias' before so I'm not sure why this would be an issue here...
As you can see, I've been trying to figure this issue out, but haven't had much luck... :( -
Combine 2 Queries (from SAME table) into a SINGLE query
I have this two queries (from SAME table), and want to combine into one SINGLE query, how?
How can we use CASE WHEN THEN for such situation?
Query1:
SELECT t_inner.*,
Floor(t_inner.ProductiveTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.ProductiveTime,3600) / 60),2,0) || 'min:' AS Productive_Time,
Floor(t_inner.OperatorDownTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.OperatorDownTime,3600) / 60),2,0) || 'min:' AS OperatorDown_Time
FROM
(SELECT SYSTEMTYPE,
sum(TIME_TEST + TIME_STEP) AS ProductiveTime,
sum(TIME_IDLE) AS OperatorDownTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO != '9999999999'
GROUP BY SYSTEMTYPE ) t_inner
Query 2:
SELECT t_inner.*,
Floor(t_inner.MachineDownTime/ 3600) || 'hr ' || LPAD(Floor(Mod(t_inner.MachineDownTime,3600) / 60),2,0) || 'min' AS MachineDown_Time
FROM
(SELECT SYSTEMTYPE,
sum(TIME_IDLE) AS MachineDownTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO = '9999999999'
GROUP BY SYSTEMTYPE) t_inner
see http://postimg.org/image/koq87iyyz/ and
http://postimg.org/image/fv3zxa38nwith the first query,
SELECT t_inner.*,
Floor(t_inner.ProductiveTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.ProductiveTime,3600) / 60),2,0) || 'min' AS Productive_Time
FROM
(SELECT SYSTEMTYPE,
--sum(TIME_TEST) AS TIME_TEST,
--sum(TIME_SYSTEM) AS TIME_SYSTEM,
--sum(TIME_STEP) AS TIME_STEP,
--sum(TIME_IDLE) AS TIME_IDLE,
sum(TIME_TEST + TIME_STEP) AS ProductiveTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO != '9999999999'
GROUP BY SYSTEMTYPE) t_inner
it gives output as from
http://postimg.org/image/koq87iyyz/
with the second query,
SELECT t_inner.*,
Floor(t_inner.MachineDownTime/ 3600) || 'hr ' || LPAD(Floor(Mod(t_inner.MachineDownTime,3600) / 60),2,0) || 'min' AS MachineDown_Time
FROM
(SELECT SYSTEMTYPE,
sum(TIME_IDLE) AS MachineDownTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO = '9999999999'
GROUP BY SYSTEMTYPE) t_inner
it gives output as from
http://postimg.org/image/fv3zxa38n/
I want to come those 2 queries into a single query, such that it gives both outputs as above. Let me know if you need any other information. thanks. -
Compare two records column by column in same table
Hi All,
I have an address table with ID as the PK but there can be more than one ID. I need to take the latest address record and first see if that same ID has a previous address record and if so, compare each column to see if the data has changed. I only need to compare the latest record with the next latest record.
I cannot figure this out at all. I can of course use the MAX function to get the latest address records but do not know how I can pull the next latest address record that matches the ID and compare each column.
Sample table:
ID street city state zip effective_date
1 123 main chicago IL 60111 3-7-2012
2 34 N 13th new york NY 18374 3-7-2012
3 15 N main Dallas TX 47389 3-7-2012
1 89 N main chicago IL 60111 1-5-2012
1 16 East St columbus OH 47382 12-10-2011
2 34 N 13th new york NY 18374 10-7-2011
2 15 S Elm new york NY 18374 09-1-2011
3 15 N main Dallas TX 47389 10-4-2011
SO...in the table above using today as the latest record date, based of my criteria I would only want to pull record ID 1 and 2 since the next most recent record for those IDs have had at least one of their address data change. ID 3 has exactly the same address data so I would not consider that in my criteria.
Can i do this with SQL only or will i need to create a procedure or function?
Any help is appreciated
BenBen C wrote:
Hi All,
I have an address table with ID as the PK but there can be more than one ID. You mean there can be more than one row with tha same ID, right? (There can be more than one ID, also.)
I need to take the latest address record and first see if that same ID has a previous address record and if so, compare each column to see if the data has changed. I only need to compare the latest record with the next latest record.
... Sample table:Whenever you have a problem, please post CREATE TABLE and INSERT statements for the sample data, and the exact results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using.
Can i do this with SQL only or will i need to create a procedure or function?You don't need PL/SQL, if I understand your requirements. You can do something like this:
WITH got_analytics AS
SELECT id, street, city, state, zip, effective_date
, COUNT (*) OVER ( PARTITION BY id ) AS cnt
, ROW_NUMBER () OVER ( PARTITION BY id
ORDER BY effective_date DESC
) AS r_num
FROM table_x
-- WHERE ... -- If you need any filtering, put it here
SELECT id, street, city, state, zip, effective_date
FROM got_analytics
WHERE cnt > 1
AND r_num <= 2
ORDER BY id
, effective_date
;This will show the most recent 2 rows for each id that has 2 (or more) rows.
You can modify it to only include ids where there was some change in street, city, state or zip between those 2 rows.
WITH got_analytics AS
SELECT id, street, city, state, zip, effective_date
, COUNT (*) OVER ( PARTITION BY id ) AS cnt
, ROW_NUMBER () OVER ( PARTITION BY id
ORDER BY effective_date DESC
) AS r_num
FROM table_x
-- WHERE ... -- If you need any filtering, put it here
, got_unique_cnts AS
SELECT id, street, city, state, zip, effective_date
, COUNT (DISTINCT '~' || street) OVER (PARTITION BY id) AS street_cnt
, COUNT (DISTINCT '~' || city) OVER (PARTITION BY id) AS city_cnt
, COUNT (DISTINCT '~' || state) OVER (PARTITION BY id) AS state_cnt
, COUNT (DISTINCT '~' || zip) OVER (PARTITION BY id) AS zip_cnt
FROM got_analytics
WHERE cnt > 1
AND r_num <= 2
SELECT id, street, city, state, zip, effective_date
FROM got_unique_cnts
WHERE street_cnt > 1
OR city_cnt > 1
OR state_cnt > 1
OR zip_cnt > 1
ORDER BY id
, effective_date
;This assumes that street, city, state and zip are all VARCHAR2s. If any of those columns is NULL on one row, and not NULL on the other row for that ID, that counts as a difference.
Edited by: Frank Kulash on Mar 7, 2012 3:37 PM
Edited by: Frank Kulash on Mar 7, 2012 3:41 PM -
How to compare two fields from the same table in the select statement
Hi, friends
I try to compare tow fields from the same table, but no result,
For example, this
data: cptotchek tyep i.
select count(*) into cptotchek
from aufk where erdat = aufk-idat2 .
The result is cptotchek = 0, but there are the records in aufk , where, aufk-erdat = aufk-idat2.
Please, help me, i don't use the loop statement for optimize my program.
RegardsHi ,
it will not return any value when you are using column of same table
such as Date Field , Because while Using Aggregate Function it will not check with self column
. For that you have to take data in one internal table and then you can work on it .
And if you are worried about Performance it will not affect , untill you are selecting only required data .
you can try this way .
data: cptotchek type i.
types : begin of w_aufk.
include structure aufk .
types : end of w_aufk .
data : it_aufk type standard table of w_aufk with header line .
select * into corresponding fields of table it_aufk
from aufk .
loop at it_aufk .
if it_aufk-erdat = it_aufk-idat2 .
write : / it_aufk-erdat , it_aufk-idat2 .
else .
delete it_aufk .
endif .
endloop.
Regards
Deepak. -
Need to compare values in two columns of one table against values in two columns in another table
Hi, as the title reads, I'm looking for an approach that will allow me to compare values in two columns of one table against values in two columns in another table.
Say, for instance, here are my tables:
Table1:
Server,Login
ABCDEF,JOHN
ABCDEF,JANE
FEDCBA,SEAN
FEDCBA,SHAWN
Table2:
Server,Login
ABCDEF,JOHN
ABCDEF,JANE
FEDCBA,SHAWN
In comparing the two tables, I'd like my query to report the rows in table1 NOT found in table2. In this case, it'll be the 3rd row of table one:
Server,Login
FEDCBA,SEAN
Thanks.create table Table1([Server] varchar(50), Login varchar(50))
Insert into Table1 values ('ABCDEF','JOHN'),('ABCDEF','JANE'),('FEDCBA','SEAN'),('FEDCBA','SHAWN')
create table Table2([Server] varchar(50), Login varchar(50))
Insert into Table2 values ('ABCDEF','JOHN'),('ABCDEF','JANE'), ('FEDCBA','SHAWN')
select [Server] ,Login from Table1
Except
select [Server] ,Login from Table2
select [Server] ,Login from Table1 t1
where not exists(Select 1 from Table2 where t1.[Server] = t1.[Server] AND Login=t1.Login)
drop table Table1,Table2 -
How to compare two rows from two table with different data
how to compare two rows from two table with different data
e.g.
Table 1
ID DESC
1 aaa
2 bbb
3 ccc
Table 2
ID DESC
1 aaa
2 xxx
3 ccc
Result
2Create
table tab1(ID
int ,DE char(10))
Create
table tab2(ID
int ,DE char(10))
Insert
into tab1 Values
(1,'aaa')
Insert
into tab1 Values
(2,'bbb')
Insert
into tab1 Values(3,'ccc')
Insert
into tab1 Values(4,'dfe')
Insert
into tab2 Values
(1,'aaa')
Insert
into tab2 Values
(2,'xx')
Insert
into tab2 Values(3,'ccc')
Insert
into tab2 Values(6,'wdr')
SELECT
tab1.ID,tab2.ID
As T2 from tab1
FULL
join tab2 on tab1.ID
= tab2.ID
WHERE
BINARY_CHECKSUM(tab1.ID,tab1.DE)
<> BINARY_CHECKSUM(tab2.ID,tab2.DE)
OR tab1.ID
IS NULL
OR
tab2.ID IS
NULL
ID column considered as a primary Key
Apart from different record,Above query populate missing record in both tables.
Result Set
ID ID
2 2
4 NULL
NULL 6
ganeshk -
Compare two members from the same dimension in HFR
Hi,
Is it possibe to compare two members from the same dimension in HFR? The requirement is to compare Year and Week members from the same dimension. The Week date will be selected from POV. The corresponding Year date should be displayed in the report. Week dates are in the format W2008-03-07 and Year dates are in YTD2008-03-07.
The dates are same except the preceding character.I am unable to compare these two. In my understanding there's no substring or replace functions in HFR.
Kindly help. Thanks in advance.
Regards,
UmaHi,
How is your database structured? it may be possible to use the 'RelativeMember' function if it will always be the same number of steps between the 'W' member and the 'YTD' member, e.g. if your hierarchy is something like:
Time
.Weeks
..W2008-03-07
..W2008-03-10 etc.. for 52 weeks
.YTD
..YTD2008-03-07
..YTD2008-03-10 etc.. for 52 weeks
In your report select 'Current Point of View for Time' in one row/column and in the other use:
RelativeMember set up as follows:
Member: Current Point of View for Time
Offset: 52
Hierarchy: Time
RelativeMemberList: Lev0, Time
UseFirstDescendant: leave unselected
Hope this helps
StuartGame
www.analitica.co.uk -
Combining the same column from 2 tables with distinct result.
I have 2 tables with identical name columns. One is current people and the other is historical people. I want a select that returns any name that is in either table. I want each name listed only once. I want to see 1 entry for each name if it is in the current table, the historical table, or both tables. I can easily do a select distinct on each table but how do I join the queries to get 1 result set with no duplicates? The name column is not a key field and I don't want any other columns from either table.
Just a simple UNION:
select name
from current
union
select name
from historical; -
Hi Friend.
I have to write two triggers on same table for auditing different columns of different users(may be different modules).
I will have an audit table in which i will insert data such as (user_id,module_id,column_name,old_col_val,new_col_val,timestamp)
Now different users from different modules will update the data on same table may be same columns from different front end forms!
If we write directly, we will not be able to know which column is updated by which user.
My question is in this case how can we control the triggers to raise differently?You can use WHEN clause to fire a trigger only when some condition is true - you can check an user also,
look at simple example:
- suposse we have two users US1 and US2:
C:\>sqlplus sys as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Pn Gru 6 13:14:22 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL> create user us1 identified by us1;
User created.
SQL> create user us2 identified by us2;
User created.
SQL> grant connect, resource to us1, us2;
Grant succeeded.
SQL> grant create public synonym to us1, us2;
Grant succeeded.and suposse we have a table with three columns + audit table:
SQL> connect us1
Enter password:
Connected.
SQL> create table tab123(
2 col1 number,
3 col2 number,
4 col3 number);
Table created.
SQL> create table audit_tab123(
2 username varchar2(100),
3 col1 number,
4 col2 number,
5 col3 number );
Table created.
SQL> grant select, update, insert on tab123 to us2;
Grant succeeded.
SQL> grant select, update, insert on audit_tab123 to us2;
Grant succeeded.
SQL> create public synonym tab123 for tab123;
Synonym created.
SQL> insert into tab123 values( 1, 1, 1 );
1 row created.
SQL> commit;
Commit complete.We want a trigger that is fired only by user US1 and only after update of COL1 and COL2
(COL3 is ignored):
SQL> connect us1/us1
Connected.
SQL> CREATE OR REPLACE TRIGGER Trig_123_US1
2 AFTER UPDATE OF col1, col2 ON tab123
3 FOR EACH ROW
4 WHEN ( user = 'US1' )
5 BEGIN
6 INSERT INTO audit_tab123( username, col1, col2 )
7 VALUES( user, :new.col1, :new.col2 );
8 END;
SQL> /
Trigger created.And we want a second trigger that is fired only by user US2 and only after update of COL2 and COL3
(COL1 is ignored):
SQL> connect us1/us1
Connected.
SQL> CREATE OR REPLACE TRIGGER Trig_123_US2
2 AFTER UPDATE OF col2, col3 ON tab123
3 FOR EACH ROW
4 WHEN ( user = 'US2' )
5 BEGIN
6 INSERT INTO audit_tab123( username, col2, col3 )
7 VALUES( user, :new.col2, :new.col3 );
8 END;
9 /
Trigger created.and now let test our triggers:
SQL> connect us1/us1
Connected.
SQL> update tab123 set col1 = 22;
1 row updated.
SQL> update tab123 set col2 = 22;
1 row updated.
SQL> update tab123 set col3 = 22;
1 row updated.
SQL> commit;
Commit complete.
SQL> select * from audit_tab123;
USERNAME COL1 COL2 COL3
US1 22 1
US1 22 22
SQL> connect us2/us2
Connected.
SQL> update tab123 set col1 = 333;
1 row updated.
SQL> update tab123 set col2 = 333;
1 row updated.
SQL> update tab123 set col3 = 333;
1 row updated.
SQL> commit
2 ;
Commit complete.
SQL> select * from us1.audit_tab123;
USERNAME COL1 COL2 COL3
US1 22 1
US1 22 22
US2 333 22
US2 333 333As you see, each trigger is fired only once, first triger only for user US1 and columns COL1 and COL2,
and second trigger only for user US2 and only after update of COL2 and COL3.
I hope this will help. -
Want to update a column with different column of same table
I have a table TEST_CDR which is having 250 millions records also having partition by hash.
there are two column in this table ID and CDR_ID want to update ID in CDR_ID but it take too much time like 24 hours or more.
please suggest me a simple way.Hi,
You can try this. but be careful about your backups and go through CTAS,nologging and parallel concepts...
Please refer this link.
http://www.dba-oracle.com/t_fast_batch_updates_ctas.htm
http://www.dba-oracle.com/t_nologging_append.htm
http://www.dba-oracle.com/t_efficient_update_sql_dml_tips.htm
http://eriglen.blogspot.in/2011/08/ctas-create-table-as-select-with.html
1.CTAS with nologging and parallel..
SQL> create table test_cdr_1(id,cdr_id) nologging parallel as select id,id from test_cdr;
2.rebuild indexes, triggers and constraints to test_cdr_1
3.rename test_cdr to bkup_test_cdr;
4.rename test_cdr_1 to test_cdr;
Regards,
ragunath.
Maybe you are looking for
-
Split Tunnel VPN and routing public ip traffic
Hi Everyone, I have my split tunnel vpn working well but I need to make an adjustment. We have a few systems in the "cloud" and we only allow access from our corporate WAN IP to those servers. I need to be able to access those servers via VPN con
-
Hi I have changed my country from India to Oman. Now when i try to update or download anyu application, the message," Your account is not valid for use in Indian Store. You must switch to the Omani Store before purchaseing" comes. In Itune account de
-
Need some expert help on this one
My PPC 10.4.11 mac is running very very slow with plenty of disk space and when I try to verify permission, repair permissions etc. disk utility freezes up to the point where I have to cold shut off the computer. Issues started yesterday when a page
-
Process instances stop at timer event
Hi, I modelled a process with intermediate timer event. When this timer expires an automatic activity is invoked which checks certain conditions. If these conditions are not met the process token returns to the timer until the conditions are met and
-
PRE/Mac installation errors (was Please Help with PSE 12 Download)
Can anyone help with a .CPP-283 and a .CPP-683 error? [/Adobe/premiere/elements/main/CAHeadless/Make/Mac/../../Src/CAHeadless.cpp-683] [/Adobe/premiere/elements/main/MediaCore/ASL/Foundation/Make/Mac/../../Src/DirectoryRegist ry.cpp-283] I've spen th