SQL & PL/SQL :: Comparing Nested Tables For Equality?

Jul 1, 2013

SF at oracle.com/technetwork/issue-archive/o53plsql-083350.html states that you can compare two database tables (of the same structure) by defining a nested table type (using %ROWTYPE) and two NT variables of that type, and loading the contents of each table into its respective NT variable, before comparing them using the = operator. Having read the Oracle documentation which states that you can only compare NTs for equality if they don't contain record types, I was surprised to read this, but figured I would try it because I must be misunderstanding SF, but it didn't work.

SCOTT@ORCL> create table empcopy3 as select * from emp;

Table created.

declare
type emp_ntt is table of emp%rowtype;
emp_nt1 emp_ntt;

[Code]....

But SF goes on to say he timed the execution of his NT equality method, comparing it with a SQL-only equivalent, and so I must be missing something. My understanding is that using %ROWTYPE declares a record type.

View 3 Replies


ADVERTISEMENT

SQL & PL/SQL :: Comparing Data In Two Tables Row By Row

Sep 23, 2011

I have two databases.

one is "ora" it is a 8i version
2nd is "orcl" it is a 11g version

"Oracle" is the my local database. i wrote following program for comparing the row by row data in both the tables.
Q)Is it BEST practice? If not let me know the best practice to compare data in tables?
Q) If am not using the order by clause its giving me wrong output even though both the data tables has same data. WHY?

DECLARE
v_emptest1 EMP_TEST1%ROWTYPE;
v_emptest2 EMP_TEST1@ora%ROWTYPE;
v_suc_flg NUMBER := 0;
v_cnt1 NUMBER:=0;
[code].......

View 9 Replies View Related

SQL & PL/SQL :: Comparing Two Tables Data

Mar 16, 2010

I want to do a comparision for the missing rows between two diffrent tables

TBL1 and TBL2 both with the same structure but with diffrent data some data is identical. though my data is huge i wanted to make sure the technique i am using

View 8 Replies View Related

SQL & PL/SQL :: Comparing Tables In Two Different Databases

Apr 13, 2011

As part of our project, we need to perform table comparisons in two different databases. I am currently looking for various options to accomplish this.

One of them is doing minus operation between these two tables. Also, i have looked at the data compare option in toad utility.

View 1 Replies View Related

Nested Tables By DBLINK

Feb 1, 2011

There's a table T with a nested table within it on the master database. I need to mantain a materialized view of the table T on a remote database.

I get this error: QUOTE ORA-22804: remote operations not permitted on object tables or user-defined type columnsIs there any recommended workaround of this problem? The remote data must have the same structure as the master one.

The data should be refreshed every day, the data changes moderately, there are more or less 500 records.

View 2 Replies View Related

SQL & PL/SQL :: Set Operations With Nested Tables?

Aug 20, 2010

In the example below I believe I have created a Nested Table of PL/SQL type and have tried various references to get the SET operation to work, line containing MEMBER OF. Taking the example below from the oracle documentation I have two questions.

1) As I understand it I should be able to use SET operations on Nested tables of PL/SQL types, (I am not using the CREATE OR REPLACE DDL statement prior to the DECLARE block.).
Is this correct?
2) I am assuming that I have to reference the record, can I reference by its type / row instance or can I only retrieve the record like a Cursor Fetch solution, (which would defeat the purpose.).

Is this a SQL to PL/SQL <> PL/SQL to SQL problem?

download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/collections.htm

Example 5-24 Comparing Nested Tables with Set Operator
SET serveroutput ON
DECLARE
answer BOOLEAN;

[code]...

View 1 Replies View Related

Use Of Query Clause For Nested Tables During Export

Aug 30, 2010

I have a query regarding nested tables while exporting. Are we not allowed to use Query clause during the export of nested table?

I am getting the error:
"EXP-00053: unable to execute QUERY on table NT_LP_COREBAL_MAINT because the table has inner nested tables
Export terminated successfully with warnings."

The exp command we are using is:
exp XXXX/XXXX@XXXX file=test1.dmp log=test1.log tables=nt_lp_corebal_maint query='where domain_id=10110307'.

View 1 Replies View Related

SQL & PL/SQL :: Search In Nested Tables And Insert Result Into New?

Mar 15, 2011

How can I search in Nested Tables ex: (pr_travel_date_range,pr_bo_arr) using the SQL below and insert the result into a new Nested Table: ex:g_splited_range_arr.

Here are the DDL and DML SQLs;*Don't worry about the NUMBER( 8 )*

CREATE OR REPLACE TYPE DATE_RANGE IS OBJECT ( start_date NUMBER( 8 ), end_date NUMBER( 8 ) );
CREATE OR REPLACE TYPE DATE_RANGE_ARR IS TABLE OF DATE_RANGE;
DECLARE
g_splited_range_arr DATE_RANGE_ARR := DATE_RANGE_ARR( );

[code]...

Or can I create a VIEW with parameters of Nested Tables in it so I can simply call

SELECT *
BULK COLLECT INTO g_splited_range_arr
FROM view_split_date(g_travel_range,g_bo_arr);

View 7 Replies View Related

Date Equality In Select Statement

Sep 3, 2013

Date equality in select statement giving 0 result even table contains record matching to it.

1- select *from  EOE_POC.PRODUCT_TEST_REPORT where CREATE_DATE = '03-SEP-13'  
2 - select *from  EOE_POC.PRODUCT_TEST_REPORT where CREATE_DATE >= '03-SEP-13' 

above query (2nd one) is giving 2 records.But I am intend to check for equality not greater

View 5 Replies View Related

SQL & PL/SQL :: Transform NOT EXIST Subquery In LEFT OUTER JOIN With Nested Tables?

Mar 22, 2012

these are the sample data :

CREATE OR REPLACE TYPE CourseList AS TABLE OF VARCHAR2(64);
CREATE TABLE department (
courses CourseList)
NESTED TABLE courses STORE AS courses_tab;
INSERT INTO department (courses)VALUES (CourseList('1','2','3'));

[code]....

The query returns the correct data, CourseList that are not subset of any other CourseList of the table.

I am trying to convert this not exists in a left outer join query to check if the performance is better, but I don't know how to do it.

I was making some variations of this code :

select d1.courses c_1, d2.courses c_2
from department d1,department d2
where d1.courses<>d2.courses(+);

but it is now working.

View 3 Replies View Related

SQL & PL/SQL :: Comparing One Row With Other Within Same Table

May 2, 2012

I have a requirement to get the count of those records whose department is not changed since they have joined the organization.
Script:

CREATE TABLE ddumps(orgid NUMBER, orgdate DATE, orgdept VARCHAR2(10))
/
INSERT INTO ddumps VALUES(1,'01-JAN-1999','ORG1')
/
INSERT INTO ddumps VALUES(1,'01-JAN-2000','ORG2')
/
INSERT INTO ddumps VALUES(1,'01-JAN-2001','ORG2')
/
INSERT INTO ddumps VALUES(2,'01-JAN-1999','ORG1')
/
INSERT INTO ddumps VALUES(2,'01-JAN-2000','ORG1')
/
INSERT INTO ddumps VALUES(2,'01-JAN-2001','ORG1')

ORGID ORGDATE ORGDEPT
1 1/1/1999 ORG1
1 1/1/2000 ORG2
1 1/1/2001 ORG2
2 1/1/1999 ORG1
2 1/1/2000 ORG1
2 1/1/2001 ORG1

since the orgid 1 has changed the dept from org1 to org2 I do not want this to be appeared in the final count. Results should only include the orgid 2 since it didn't changed any dept.

View 11 Replies View Related

Trimming Strings - Comparing?

Jul 26, 2007

I have 2 strings that I want to compare for example

string1 = 'ABC~AB/10/1234'
string2 = 'ABC~AB/10/1234~.....'

There could be anything after the 2nd ~ in string 2 is there a easy way of trimming string2 to the first 14 Characters? Or do I have to find the 2nd instance of ~ and then remove everything after (and including) that?

View 2 Replies View Related

Comparing Timestamps In ORACLE

Mar 5, 2008

How to select the transactions out of the database that occurred within 70 seconds of each other. The toll_date field is a TIMESTAMP field.

Problem is, I seem to only get transactions that occurred within 70 minutes of each other. On the timestamp field I break the math down into the seconds in a day and I add 70. I then subtract that value and add that value to the timestamp and I should get anything between those values right?

SELECT Acct_ID, Ln, Tag_Rd, COUNT(*)
FROM (
SELECT T1.Account_ID Acct_ID, T1.Tag_Read Tag_Rd, T1.Revenue_Date Rev_Date, T1.Toll_Date, T1.Lane_ID, T1.Plaza, T1.Lane Ln, T2.Toll_Date, T2.Plaza, T2.Lane
FROM Toll T1
JOIN Toll T2
[code]......

View 6 Replies View Related

SQL & PL/SQL :: Comparing Two Decimal Values

Nov 5, 2011

Recently i have started working on PLSQL coding. I have a requirement. Either error or un-processed record count is 90% of to be processed records then the script has to fail. Currently I am having a situation where error count is 1 and total to be processed is also 1.

in the below
V_ERR is error count
V_UPS is un processed count
V_PROCESSED_COUNT is total to be processed.

I am expecting PASS result but it is giving FAIL.

DECLARE
V_ERR NUMBER:=0;
V_UPS NUMBER:=0;
V_PROCESSED_COUNT NUMBER:=0;
NIN NUMBER;
BEGIN
V_PROCESSED_COUNT:=1;
[Code] .......

View 1 Replies View Related

Forms :: Comparing Date In 6i

Aug 3, 2011

I am working in form 6i, database 9i. I have datablock on table t1.

table t1: name(varchar2), date(varchar2)

datablock: name(varchar2), date(varchar2)[i have insert date with time stamp]

for date column, i am inserting date with time stamp.While querying data, user just enters only date(no time stamp), i should be able to query data. I tried in data block where condition

WHERE: substr(date,1,11)=nvl(:block.date,substr(date,1,11)

i am not able to retrieve data through date, through name it's working fine.how to retrieve data by only entering date (without time stamp)

View 13 Replies View Related

PL/SQL :: Comparing Two Counts Using Subquery?

Feb 10, 2013

Managed to confuse myself significantly. I essentially want to write a query to determine when two counts are the same using a subquery.

Eg:

R(x,y)
Select count(x)
from R
group by x;

Then I want to run another query to determine which x's have the same count value and output these corresponding x's.

View 6 Replies View Related

PL/SQL :: Not Comparing String In Case

Mar 21, 2013

i executed the below code and found that output should be 5 but it shows 7(always else part). it is not comparing string in case.

declare
check_in_date date;
var_day varchar2(11);
rate_id number;
[code]....

View 3 Replies View Related

SQL Performance When Comparing To NULL In Where Clause

Oct 29, 2008

I have a SQL query which joins several large tables (so indexes matter here) from Oracle database. In the where condition I use IS NULL with one of the date field values. Query takes 40 sec to run and if I comment this one line...it takes 1 sec to run. This date field is an index on the table and I learn that --

1. IS NOT NULL in where clause uses an index
2. IS NULL in where clause does not use an index

Is there any work around to make the query faster...other than changing all the NULL date values in the table to some string. In other words can I force it to use the index.

View 16 Replies View Related

SQL & PL/SQL :: Comparing Strings Entered In A Form?

May 27, 2011

I have to compare a string entered in a form with a series of English strings in back-end PL/SQL( using LIKE operator )

But it so happens, the string entered in the form is specific to the language used in the country. for ex. in Dutch, it is entered in Dutch language.

So on comparing, it fails as the PL/SQL compares it with English Strings.

View 4 Replies View Related

SQL & PL/SQL :: How To Fetch Column By Comparing Date

Oct 16, 2012

i am fetching one record based on date but not able to fetch the data.

in my table pdate column is there with date datatype and value is in that is:15-OCT-12 so i am fetching empid based on dates.

select empid from masterprocessdailydata where pdate=to_date('15/OCT/12','dd/MM/yy'); but not getting the empid.

View 11 Replies View Related

SQL & PL/SQL :: Comparing 2 Char Columns Using Trim?

Aug 18, 2011

I am trying to compare 2 char columns using trim to avoid space padding

CREATE TABLE TRIAL_A
(ABC CHAR(6));
INSERT ALL

[Code]....

View 11 Replies View Related

Forms :: Getting Values Of Some Column And Comparing It

Aug 6, 2010

I have got a table having column a, b , c, d, e and some values are stored in it. e.g. a, c and e have 'Y' and b and d have 'N' value in it.

How can i count with one query , how many columns have 'Y' and how many have 'N'.

cursor is one solution.

View 2 Replies View Related

SQL & PL/SQL :: Comparing Variables In Trigger Block?

Jun 29, 2010

I am having some issues in creating the following trigger. It gets created but with compilation errors.

create or replace trigger min_max_update_trg
after insert on tidlrrep
referencing new as n
for each row
declare
bltMaxSize number;
repMaxSize number;

[code].....

when i tried without the comparison if repMaxSize < bltMaxSize then it got created successfully.

View 12 Replies View Related

SQL & PL/SQL :: Utl_match Comparing Million Records?

Nov 22, 2010

the problem is: 2 tables - one with 2 million records, and the other with 8000 records.

i need to compare for each record in a table if there's a similar string on the other table.

i've created a procedure that does the following:

opens the first cursor (select col1,col2,col3,col4... from table 1)
loop
opens second cursor (select col1 from table 2)
loop
if utl_match(col1, table2.col1) > 80 then
insert col1,col2,col3,col4... into tableX
end if
close second cursor
close first cursor

the thing is that this procedure takes forever to end...about 8 days.

is it because im using the utl_match function? is there a way to speed this up?

View 13 Replies View Related

SQL & PL/SQL :: Grouping To Be Done By Comparing 2 Rows In A Table?

Feb 15, 2011

I'm using oracle 10g.I have a table with 4 columns

main_group-----id--------start_date------------end_date
M1-------------1---------07FEB11---------------10FEB11
M1-------------2---------09FEB11---------------11FEB11
M1-------------3---------10FEB11---------------12FEB11
M1-------------4---------13FEB11---------------16FEB11
M2-------------5---------18FEB11---------------21FEB11
M2-------------6---------19FEB11---------------24FEB11
M2-------------7---------26FEB11---------------27FEB11

i need to group the id's which are having overlapping dates and the output should be

main_group-----id--------start_date------------end_date
M1-------------1---------07FEB11---------------10FEB11------G1
M1-------------2---------09FEB11---------------11FEB11------G1
M1-------------3---------10FEB11---------------12FEB11------G1
M1-------------4---------13FEB11---------------16FEB11------G2
M2-------------5---------18FEB11---------------21FEB11------G3
M2-------------6---------19FEB11---------------24FEB11------G3
M2-------------7---------26FEB11---------------27FEB11------G4

I can give you the logic first i'll sort the start_date(already sorted in given example), then i'll compare the 2'nd id start date with 1'st id end date if it is less than the 1'st id end date, which means overlapping is there, then i'll group those 2 id's in to same group if not group them into 2 different groups.

View 7 Replies View Related

Comparing Index And PK Of A Table Between Instances?

Dec 2, 2012

I am about to compare Indexes and PK's(Constraint) of 3 instances.

What DBA table/s should i use best? The comparison is done to a specific schema only.

PS:Which is better dba_ind_columns or dba_objects?

View 10 Replies View Related

SQL & PL/SQL :: Comparing Multiple Columns According To Rows From Same Table

Aug 25, 2011

I am new to oracle, I have request to build a query,

we have table that generates data from 7am to 20pm for eavery hour it generates 4 rows and has 43 session values as 43 columns.

Now i want to find for every hour which is the hights session value at what time. in one hour it runs four times like 7, 7:15, 7:30 and 7:45 and each row has date, time and 43 session columns in table...

View 12 Replies View Related

SQL & PL/SQL :: Comparing Date Ranges Against All Rows In Same Table

Oct 30, 2011

I'm looking to see if there's a solution to my problem that I can use within the context of my business application interface into an Oracle RDMS. I have access to write custom SQL statements and functions, but I am NOT able to create stored procedures using the interface I have.

The challenge I am having is comparing date ranges. I have a table containing two columns labelled START TS TIME and END TS TIME, both of type 'Date'. I have figured out how to query each row against a given Next Session Start and Next Session End and determine if each row overlaps that row.

I need a procedure that will be recursive: that is, set Next Session Start and Next Session End to START TS TIME and END TS TIME of the first row, compare all rows against it, then set Next Session Start and Next Session End to the next row, compare all rows, ... for all rows in the table. I want to know what the maximum number of matches is (i.e. the most time periods that overlap).

If I could use a stored procedure I could complete this query easily. Is there other techniques (i.e. functions) available to leverage in order compare each row of date ranges against ALL rows in the same table?

View 4 Replies View Related

Forms :: How To Update Current Row Comparing It With Existing Value

Jul 14, 2013

I have master-detail form I would like to update the emp1 table on the base of current value of dept table deptno and emp table ename .

update emp1
set ename = :emp.ename
where ename =
(select ename from emp e
where e.ename=:emp.ename
and e.deptno=:dept.deptno);

I try the above query but it did not able to update emp1 table.

View 12 Replies View Related

Server Administration :: Schema Comparing Tool

Apr 8, 2012

we have a two different databases at different locations and on different servers, like one in our company with SID='A' and remote database with SID='B', We have recently implemented new module in database 'A' by creating lots of tables, functions, indexes, sequences, synonyms etc and now we need to install this on 'B' but the problem is we have not documented which tables we created, first we need to create a DB link between these two and then we need a tool to compare what are all the tables that we need to create in database 'B' , is there a tool for doing all this.

View 7 Replies View Related







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