Print Mismatch Values From Two Tables?

Nov 6, 2012

I've 2 identical tables of 300+ columns each,and each of table is having pk as combination of 2 fields.There are some fields where data is not matching. need a query which will use these two tables and return the following-

1. primary key columns

2. null value for fields where data is matching

3. data for columns where there is data mismatch.

View 4 Replies


ADVERTISEMENT

Performance Tuning :: Compare Current Row Values With Previous One Until Mismatch

Nov 2, 2011

We have employee salary table which will have salary of an employee on daily basis (only working days). Below is the table structure:

emp_salary
----------
emp_id NUMBER(15) NOT NULL
effective_date DATE NOT NULL
salary NUMBER(15) NOT NULL
Primary key - emp_id, effective_date
This table is yearly partitioned

I have to find out how long the salary is not changed for an employee from given date, and last salary. I am using below query to do this:

WITH salary_tab AS
(SELECT effective_date, salary,
(CASE
WHEN (LAG (salary) OVER (PARTITION BY emp_id ORDER BY effective_date ASC) =
salary
)
THEN 0
ELSE 1
END
) changed_ind
FROM emp_salary
WHERE emp_id = 12345
[code]....

The cost of this query is 1677 and it is taking around 60 msec to complete. When I run this query for around 2000 employees in a loop it is taking around 3 minutes to complete.

The main bottleneck of this query is in the with clause where I am processing the entire history instead of stopping after first change.

View 7 Replies View Related

SQL & PL/SQL :: Unique Values - Print Output Of Table

Dec 9, 2011

I am stuck with this query.

I have a table "xyz" as -->>

SQL> select * from xyz;

A B
---------- ----------------------------------------
1 Hello
2 Hello
3 No Hello
4 No Hello
5 Hello
6 Hello
7 Hello

I want to print the output of this table as -->>

A B
---------- ----------------------------------------
1
2 Hello
3
4 No Hello
5
6
7 Hello

To make it more clear, I just want that whenever the value f column "B" changes then only its value should be printed, else it should be NULL. And if "B" has same value for all the records then the value of "B" should be printed at the last.

Either of SQL or PLSQL would d for me.

View 11 Replies View Related

SQL & PL/SQL :: Print No Results If More Than 10 Records Else Print The Output

Mar 24, 2011

I have this SQL statement:

WITH data
AS (SELECT user_id,
jc_name,

[Code]....

I wish to do something like

if results > 10 print an error message (and no results)
if results < 10 print the results/output

View 1 Replies View Related

SQL & PL/SQL :: Primary Key Values To Query More Than 25 Tables

Oct 6, 2011

I have two primary key values based on that I would need to query at least 25+ tables(each of these tables might have both primary key columns or either one to query) to extract data for my 150 columns and load it onto my target table.

View 2 Replies View Related

SQL & PL/SQL :: Joining Tables - Copy Values Of One Row To Other?

May 20, 2010

consider the following

WITH table1 AS
(
SELECT 345 id, To_Date('1/31/2010', 'mm/dd/yyyy') dt, 123 cid, 'test' txt FROM dual UNION ALL
SELECT 345 id, To_Date('2/1/2010', 'mm/dd/yyyy') dt, 121 cid, 'test2' txt FROM dual UNION ALL
SELECT 345 id, To_Date('2/2/2010', 'mm/dd/yyyy') dt, 112 cid, 'test3' txt FROM dual UNION ALL
SELECT 345 id, To_Date('2/3/2010', 'mm/dd/yyyy') dt, 162 cid, 'test4' txt FROM dual UNION ALL

[code]..

i want to output the following:

{code}
IDDT CIDTXT
3451/31/2010123test6
3452/1/2010121test2
3452/2/2010112test3

[code]....

as you can see, i want to join both tables (table1 and ov_dates) and take dt from ov_dates table look it up in table1 and thengrap ov_dt and looking up in table1 and copy values of one row to the other.

for example, in ov_dates i have 3/31 dt and 4/7 ov dt. i will look for 3/31 and 4/7 row in table 1 and copy columns values from 4/7 to 3/31you can see that cid for 3/31 stay the same (since i dont want to replace the value) but txt value was replace with value from 4/7

another examplein ov_dates we have 1/31 dt and 2/5. so i go into table1 get 1/31 and 2/5 row and copy values from 2/5 into 1/31/ as you can see the txt column value for 1/31 becametest6 since it was taking from 2/5. the same thing for the rest ofdata

View 10 Replies View Related

Mismatch In Counts

Jan 28, 2012

I have taken the export backup of a table using the following command

userid=system/manager@DBATEST
file=abc.dmp
log=abc.log
Tables=X.S_ORG_EXT_X
feedback=100000
buffer=10000000
[code]......

but on querying the table it shows the number of rows as

select count(*) from X.S_ORG_EXT_X;

COUNT(*)
----------
25656051

Explain why there is a mismatch in the count of the rows in the table.

View 1 Replies View Related

ASM Kernel Mismatch?

May 5, 2011

I believe I have a problem with the ASM Kernel rpm that I downloaded from Oracle OTN

my Linux OS is

[root@UKEDXDTMTDBS01A u01]# uname -r
2.6.18-194.el5

So I downloaded the x3 ASM files required

[root@UKEDXDTMTDBS01A u01]# ls -ltr *.rpm
-rw-r--r-- 1 oracle oinstall 90858 Apr 12 14:18 oracleasm-support-2.1.4-1.el5.x86_64.rpm
-rw-r--r-- 1 oracle oinstall 14176 May 5 10:10 oracleasmlib-2.0.4-1.el5.x86_64.rpm
-rw-r--r-- 1 oracle oinstall 137486 May 5 10:29 oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm

As you can see the install worked fine

rpm -Uvh oracleasm*.rpm
warning: oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
warning: oracleasm-support-2.1.4-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID b38a8516
Preparing... ########################################### [100%]

[code]...

So therefore it does not show any disks

[root@UKEDXDTMTDBS01A u01]# /usr/sbin/oracleasm listdisks
[root@UKEDXDTMTDBS01A u01]#

Am I doing something wrong -

View 5 Replies View Related

SQL & PL/SQL :: Swap Values Between Columns Across Tables In Database

Jan 28, 2011

I've recieved a recent request wherein the requirement is to swap values between columns across multiple tables in a database.Following is a visual sample of what needs to be done.

Before Swaping:

Columns Values
TABLE1.IDENTIFIER MRN123
TABLE1.MEDICARENO CHI1234567
TABLE2.MRN MRN123
TABLE3.MRN MRN123
OTHERTABLE.MRN MRN123

After Swapping:

Columns Values
TABLE1.IDENTIFIER CHI1234567
TABLE1.MEDICARENO MRN123
TABLE2.MRN CHI1234567
TABLE3.MRN CHI1234567
OTHERTABLE.MRN CHI1234567

View 12 Replies View Related

SQL & PL/SQL :: How To Replace Variables With Values In Tables And Get The Result

Nov 8, 2012

I have two tables A and B.

A
--
variable value
-------- ------
a 10
b 20

B
--
Exp
---
b-a
b*a
b/a

How can the variables be replaced with values(10,20) using a single query...?

View 2 Replies View Related

SQL & PL/SQL :: List All Tables In Database With Particular Record Values Combination

Jul 1, 2013

I have 3 tables in the Oracle database( emp, employee, emp1) which has following record values in it.

empidenamejob
7369, 'SMITH', 'CLERK'

I would like to list these 3 tables thru SQL/PLSQL, having the above record values combination. Also, the name of the columns could be different in all the tables i.e. name could be 'ename' in Emp table , and 'name' in Employee table. Is there way to do this in SQL or PLSQL ?

View 3 Replies View Related

SQL & PL/SQL :: How To Fetch Values From Other Tables In Application On-submit Process

May 4, 2012

In Oracle Apex 4.1,The Leave_transaction Table has the following Fields,

1.Leave_id
2.Emp_name
3.From_date
4.To_date
5.Remaining_days

The Emp_Master Table has the following columns,

1.Emp_id
2.Emp_Name
3.Remaining_days

Holiday_master table has the list of holiday dates as "From_Date"

I have the form based on the Leave_Transaction Table, and I have created the Process, as "On-submit-after computations and validations" and posted the following PLSQL code,

declare
days number(3);
ex_days emp_master.remaining_days%type;
new_rem_days emp_master.remaining_days%type;
begin

[code]....

If the Dates is between from_date and To_date comes in Saturday and sunday and/or if any Date is exist in the Hpliday_master table it will exclude and return the count(*) remaining dates, For example,

If the From_date is 04-may-2012' and To_date is 08-may-2012,

Here the dates 5th may and 6th may are "saturday" and "sunday"

and if any date between From_date and To_date is exist in Holiday_Master Table i.e say here it is 07-may-2012, Then the remaining dates are(excluding sat,sunday and dates in holiday_table),

04-may-2012,
08-may-2012.

so the count(*) is 2.

I am using the above code but still it returning 5,I think this

...where to_char(dt,'fmday') not in ('sunday','saturday') minus (select holiday_start from holiday_master))

code is not working.

View 39 Replies View Related

Compare Current With Previous Row Until Mismatch

Nov 2, 2011

We have employee salary table which will have salary of an employee on daily basis (only working days). Below is the table structure:

CODEemp_salary
----------
emp_id NUMBER(15) NOT NULL
effective_date DATE NOT NULL
salary NUMBER(15) NOT NULL

Primary key - emp_id, effective_date..This table is yearly partitioned...I have to find out how long the salary is not changed for an employee from given date, and last salary. I am using below query to do this:

CODEWITH salary_tab AS
(SELECT effective_date, salary,
(CASE
WHEN (LAG (salary) OVER (PARTITION BY emp_id ORDER BY effective_date ASC) =
salary

[code]....

For emp_id 1, if we ran this query for 10/31/2011, then it has to compare the 10/31 salary with 10/29 and do the same until the salary mismatches. In this case, salary salary mismatch occurs on 10/20, so the stale salary period is from 10/31 to 10/21 which is 7 days.Below query will give that result:

CODE
WITH salary_tab AS
(SELECT effective_date, salary,
(CASE
WHEN (LAG (salary) OVER (PARTITION BY emp_id ORDER BY effective_date ASC) =
salary

[code]...

View 1 Replies View Related

Windows :: Oracle Version Mismatch

Jul 1, 2011

I have installed oracle 10g version 10.2.0.4.0 on Windows 7 64 bit from the following link.

[URL].........

After login to SQL* plus, when i see the version, it shows as 10.2.0.3.0. Is this correct?

View 8 Replies View Related

Record Count Mismatch Between Select And Insert

Mar 20, 2013

We are trying insert records from a select query in to temporary table, some of the records is missing in the temporary table. The select statement is having multiple joins and union all which it little complex query. In simple terms the script contains 2 part 1st Part Insert in to temporary table 2nd part Select query with multiple joins, inline sub queries, unions and group by classes and conditions Eg. If we execute select statement alone it returns some count for example => 60000 After inserting into the temp table, in temp table the count is around 42000 why is the difference?

It is simple bulk inserts... insert in to temp table select * from xxx. also, there is no commit in between. The problem is all the records populated by the select statement are not inserted in to temp table. some records are not inserted.

Also, we had some other observation. It only happens in its 2nd execution and not its first run. Hope there might be some cache problem
Even, we also did not believe that. We are wondering. In TOAD, we tested however at times it happens. In application jar file, after "insert in to temp select * from xxx" we take the i. record count of temp table and ii. record count of "select * from xxx" separately but both doesn't match. Match only at 1st time.

View 3 Replies View Related

PLS-00386 / Type Mismatch Found At V_MF_RECORD

Apr 19, 2011

I have created a type of type OBJECT:

CREATE OR REPLACE
TYPE MF_RECORD_TYPE IS OBJECT
(name VARCHAR2(6),
.
.
.
CREATE OR REPLACE
TYPE MF_TABLE_TYPE IS TABLE OF mf_record_type;

Then in my stored procedure:

v_mf_record MF_TABLE_TYPE := MF_TABLE_TYPE();
.
.
OPEN mf_detail;
FETCH mf_detail BULK COLLECT INTO v_mf_record;
CLOSE mf_detail;

[code]....

I am getting the error: PLS-00386: type mismatch found at 'V_MF_RECORD' between FETCH cursor and INTO variables.

The thing is, that type I defined is like 90 columns, and I'm trying to avoid having to list all those columns individually in the FETCH or when I retrieve the data.

View 2 Replies View Related

Oracle Listener Version Mismatch (10g / 11g) After 11g Upgrade?

Aug 9, 2012

I had two installations of Oracle on my server (10.2.0.4 and 11.2.0.1) under different linux users. The Databases used different listeners on different ports.

I upgraded my Oracle 11g to 11.2.0.3 successfully two weeks ago. However today I just checked that I couldnt reload my Oracle 10g Listener. On further analysis (lsnrctl status) I discovered that my 10g listener's version was "TNSLSNR for Linux: Version 11.2.0.3.0" . My Start Date from lsnrctl gives me the date when my Oracle 11g was upgraded.

Now I have tried to reload my 11g listener which works normally. I cannot reload my 10g listener (TNS-01190: The user is not authorized to execute the requested listener command). When i run ps command there is no process on my server for my 10g listener. I can only see my 11g listener process after running ps command. However everybody can ping my databases on Oracle 10g but i cannot identify or kill my listener process even on server level.

View 4 Replies View Related

PL/SQL :: ORA-06525 - Length Mismatch For CHAR Or RAW Data

Nov 1, 2013

ORA-06525: Length Mismatch for CHAR or RAW dataORA-06512: at "SYS.UTL_FILE", line 127ORA-06512: at "SYS.UTL_FILE", line 1204ORA-06512: at line 14

View 20 Replies View Related

Performance Tuning :: Update Million Rows In One Table With Values From Another Tables?

Feb 15, 2011

I am trying to update a million rows in one table with the values from another tables.

Table being updated CI_ADJ_CHAR column CHAR_VAL_FK1
Table from which values will be used CK_ADJ columns (cx_id, ci_id)

The CI_ADJ_CHAR.CHAR_VAL_FK1 values match CK_ADJ.CX_ID and should be updated with the value CK_ADJ.CI_ID.

The CK_ADJ table has 1.3 million rows and both the columns have indexes defined. Table definitiuon mentioned below

The CI_ADJ_CHAR table has 14 million rows and will update 1 million rows and has an index on the ADJ_ID column but not on the CHAR_VAL_FK1 column.

View 1 Replies View Related

SQL & PL/SQL :: Multiple Values Of RULES Tables To Find Records Containing A String Format

Sep 4, 2013

Insert into PROFILE
(INSTANCE, PROFILENAME, USER_DATA, UPDATE_DATE)
Values
(138, 'Test A', 'SRC!-1,ARCHIVE_OPT!-1,DATE_FIELD!155,DATE_RULE!1,DISTINCT!1', TO_DATE('01/20/2005 13:35:33', 'MM/DD/YYYY HH24:MI:SS'));
/
Insert into RULES
(ID, NAME)
Values
(155, 'DATE_TEST');

I want a code something of this sort:

select profilename from PROFILE where user_data like '%DATE_RULE!115%';

Output will be "Test A".Now, this is just a single value from RULES table used to find the data of PROFILE table.I will have to run the query on multiple values of RULES tables to find records containing a string format of sort "DATE_RULE!<rule_no>". How to search on WILD CARDs like these?

View 5 Replies View Related

SQL & PL/SQL :: Record Count Mismatch In Dataset And Query Executed

Oct 14, 2011

I am using an query to fetch the data from oracle DB and fill dataset using oledb dataadapter in ASP.net.When i run the same query in PL/SQL i am getting 14952 records,but when i am filling it to dataset i am getting only 13700 records.

View 2 Replies View Related

Client Tools :: ORA-31180 / Type Mismatch In Invalid PL/SQL DOM Handle

Jul 23, 2010

ORA-31180: DOM Type mismatch in invalid PL/SQL DOM handle

I am getting this error while debugging one of the package in PL/SQL developer or in TOAD. Is there any setting which we need to perform at the database level to debug the packages which have the code related to XML DOM. I am asking as the same code works exactly fine at one of the test database and it gives the above error on the other database.

View 10 Replies View Related

RMAN :: Rc-datafile Mismatch Sizes - Column Bytes Shows Data Different From Real Of Files?

Sep 26, 2012

in my catalog database I see in Rc_datafile mismatch sizes - column bytes shows data different from the real sizes of files .

Does this view updated after copy of database into catalog ?

View 4 Replies View Related

How To Add And Print In Sql

Apr 23, 2012

here is my code it prints data for 1 perticular date.

instead of it printing
1
3
3
1
3
1
13
0
3
0
0
1
1
1
0
5

for whole day

I want it to add and print the total

here is code

SELECT O_ESBY_SUM.CALLS
,O_ESBY_SUM.ROWDATECREATED
FROM OB.O_ESBY_SUM O_ESBY_SUM
where To_Date(to_char(O_ESBY_SUM.CALLS.ROWDATECREATED, 'DD-MON-YYYY')) = To_Date('?DATE1::?','MM/DD/YYYY')

it prints this
for date 4/19/2012
here is screen shot

View 1 Replies View Related

SQL & PL/SQL :: How To Print Row Value In Column

Jul 20, 2010

I have table and data like

Name
-----------------
A,B,C,D,E

I would like to print the value like

Name
------------------
A
B
C
D
E

how to do this using SQL or PL/SQl.............

View 3 Replies View Related

PL/SQL :: Output Print More Than 255

Jan 2, 2013

I am getting an error while printing a sql query which is in a string inside a stored proc. I used

dbms_output.enable(1000000);

dbms_output.put_line(v_query);

and error "I get ORU-10028: line length overflow, limit of 255 bytes per line"

How do I print everything?

View 3 Replies View Related

SQL & PL/SQL :: How To Print Even Numbers Without Using MOD Function

Mar 1, 2012

How to print even numbers 1 to 10.without using the MOD Function

View 17 Replies View Related

SQL & PL/SQL :: Print Columns Of A Table

Jul 5, 2013

DECLARE
JOBSFILE UTL_FILE.FILE_TYPE;
CURSOR JOBSCUR IS
SELECT *
-- DDOCNAME,DDOCTITLE,DSECURITYGROUP,DDOCAUTHOR,DDOCTYPE,DINDATE,PRIMARYFILE,EXTRACTIONDATE,BATCH_ID
FROM TARGET_UCM ;
BEGIN
JOBSFILE := UTL_FILE.FOPEN('FILES','JOBS.TXT','W');
UTL_FILE.PUT_LINE(JOBSFILE,'Action = insert');
FOR REC IN JOBSCUR
[code]....

is there anyway to print the values of full table .i have used all column names to print .

View 6 Replies View Related

SQL & PL/SQL :: How To Print Data Between Two Dates

Oct 8, 2012

How to print data between two dates... startdate and enddate inclusive

View 2 Replies View Related

SQL & PL/SQL :: Print Update Confirmation?

Apr 13, 2013

I'm trying to create an output statement that will show that the update was successful, but everything that I'm trying doesn't seem to be working.

I have a procedure and an anonymous block that calls on the procedure.

So far after the begin in my anonymous block I have.

BEGIN
procedure_name(variable1, variable2);
dbms_output.put_line('Successfully Updated');
END;

Now I know that the procedure and the anonymous block without the dbms output works as the update takes place in the table, but I can't get any text string output to confirm this.

View 4 Replies View Related







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