Comparing two cursors
Hai friends,
I have two cursors.
one cursor have minus query(gl liability records minus ap liability records) -->4680 records
another cursor have writeoff records which are only in gl.--> 254 records
Now i want to find liability records related to writeoff records.
To acheive this.
i compared those two cursors by using cursor for loop
i got the result ..but it took 2 hours time.so could you please tell me how i overcome this problem.
Is there any option rather than cursor to compare those two sets of records.
please let me know how i improve performance in that query..
You will need to provide a lot more information than that, like table structures (at least for the relevant fields), size of the data etc. Things that can answer the questions you are going to get like:
What tells you that a liablility record is related to a writeoff record?
Is the gl_liability minus ap_liability query relevant? That is, does it identify liability records that may be realted to writeoff records?
Are these three different tables you are looking at, or one table with different record types?
John
Similar Messages
-
Hi all,
I have two different cursors of same recors.
create table temp_emp as select * from emp;
cursor cr_emp IS
select * from emp;
cursor cr_tmp IS
select * from temp_emp;
how to compare these two cursors.
Im trying to learn comparing cursors variables. I have oracle 11g, windows Vista.
Initially, I tried to compare only ename coloum:
create or replace procedure compare
IS
cursor cr_emp IS
select * from emp;
cursor cr_temp IS
select * from temp_emp;
v_cr_emp cr_emp%rowtype;
v_cr_temp cr_temp%rowtype;
emp_rownum integer;
tmpy_rownum integer;
V_CODE NUMBER;
V_ERRM VARCHAR2(64);
BEGIN
select MAX(rownum) into emp_rownum from emp;
select MAX(rownum) into tmpy_rownum from tmpy_emp;
open cr_emp;
open cr_temp;
FETCH CR_EMP INTO v_cr_emp;
FETCH CR_TEMP INTO v_cr_temp;
for emp_rownum in cr_emp
loop
for tmpy_rownum in cr_tmpy
loop
if(v_cr_emp.ename = v_cr_temp.ename)
then
dbms_output.put_line('equal');
else
dbms_output.put_line( 'not equal');
end if;
end loop;
end loop;
EXCEPTION
WHEN OTHERS
THEN
V_CODE := SQLCODE;
V_ERRM := SUBSTR(SQLERRM,1,64);
DBMS_OUTPUT.put_line ('ERROR CODE' || V_CODE || ':' || V_ERRM);
close cr_emp;
close cr_tmpy;
END;
SQL> start rain.sql
Procedure created.
SQL> exec compare
ERROR CODE-6511:ORA-06511: PL/SQL: cursor already open
PL/SQL procedure successfully completed.
Edited by: user10676396 on Apr 16, 2009 7:50 PMHi user10676396,
Hope this helps you understand the Nested loop, which I assumed you are trying to do in you program.
Note : Code not compiled and tested.
create or replace procedure compare
IS
cursor cr_emp IS
select * from emp;
cursor cr_temp IS
select * from temp_emp;
v_cr_emp cr_emp%rowtype;
v_cr_temp cr_temp%rowtype;
emp_rownum integer;
tmpy_rownum integer;
V_CODE NUMBER;
V_ERRM VARCHAR2(64);
BEGIN
select MAX(rownum) into emp_rownum from emp;
select MAX(rownum) into tmpy_rownum from tmpy_emp;
FOR REC IN cr_emp LOOP
dbms_output.put_line('For Ename in EMP : '||REC.ename ');
-- In FOR loops demo concept of nested loops
FOR TREC in cr_temp LOOP
if(REC.ename = TREC.ename)
then -- only output when you found a record in Temp
dbms_output.put_line('....EQUAL rec found in Temp : ' ||TREC.ename');
else
null ; -- Don't output if it is not equal
end if ;
END LOOP;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
V_CODE := SQLCODE;
V_ERRM := SUBSTR(SQLERRM,1,64);
DBMS_OUTPUT.put_line ('ERROR CODE' || V_CODE || ':' || V_ERRM);
close cr_emp;
close cr_tmpy;
END;
/Sanjay -
How to compare two oracle database schemas
hi all,
i want to compare and find out differences between two oracle databases. The comparison should be made on between table definition,table data,primary and foreign keys, packages and functions.
Is there any management console or tool embedded in the oracle enterprise manger?
it is really appreciate if anyone can point me towards wright direction asap.Hi ,
This script would help u a lot in comparing 2 schemas and generate a report on them.
Script:
This script will compare two Oracle schemas and generate a report of
discrepencies and this script has been used against Oracle 7.3.4, 8.0.5,
REM and 8.1.7 databases, but it should also work with other versions.
REM
REM Please note that the following schema object types and attributes are
REM not compared by this script at this time:
REM
REM cluster definitions
REM comments on tables and columns
REM nesting, partition, IOT, and temporary attributes of tables
REM snapshots/materialized views, logs, and refresh groups
REM foreign function libraries
REM object types
REM operators
REM indextypes
REM dimensions
REM auditing information
REM new schema attributes added for Oracle 9i
REM
REM Version 02-04-2002
REM
PROMPT
PROMPT Schema Comparison
PROMPT =================
PROMPT
PROMPT Run this script while connected to one Oracle schema. Enter the Oracle
PROMPT username, password, and SQL*Net / Net8 service name of a second schema.
PROMPT This script will compare the two schemas and generate a report of
PROMPT differences.
PROMPT
PROMPT A temporary database link and table will be created and dropped by
PROMPT this script.
PROMPT
ACCEPT schema CHAR PROMPT "Enter username for remote schema: "
ACCEPT passwd CHAR PROMPT "Enter password for remote schema: " HIDE
ACCEPT tnssvc CHAR PROMPT "Enter SQL*Net / Net8 service for remote schema: "
PROMPT
ACCEPT report CHAR PROMPT "Enter filename for report output: "
SET FEEDBACK OFF
SET VERIFY OFF
CREATE DATABASE LINK rem_schema CONNECT TO &schema IDENTIFIED BY &passwd
USING '&tnssvc';
SET TRIMSPOOL ON
SPOOL &report
SELECT SUBSTR (RPAD (TO_CHAR (SYSDATE, 'mm/dd/yyyy hh24:mi:ss'), 25), 1, 25)
"REPORT DATE AND TIME"
FROM SYS.dual;
COL local_schema FORMAT a35 TRUNC HEADING "LOCAL SCHEMA"
COL remote_schema FORMAT a35 TRUNC HEADING "REMOTE SCHEMA"
SELECT USER || '@' || C.global_name local_schema,
A.username || '@' || B.global_name remote_schema
FROM user_users@rem_schema A, global_name@rem_schema B, global_name C
WHERE ROWNUM = 1;
SET PAGESIZE 9999
SET LINESIZE 250
SET FEEDBACK 1
SET TERMOUT OFF
PROMPT
REM Object differences
REM ==================
COL object_name FORMAT a30
PROMPT SUMMARY OF OBJECTS MISSING FROM LOCAL SCHEMA
SELECT object_type, COUNT (*)
FROM
SELECT object_type,
DECODE (object_type,
'INDEX', DECODE (SUBSTR (object_name, 1, 5),
'SYS_C', 'SYS_C', object_name),
'LOB', DECODE (SUBSTR (object_name, 1, 7),
'SYS_LOB', 'SYS_LOB', object_name),
object_name)
FROM user_objects@rem_schema
MINUS
SELECT object_type,
DECODE (object_type,
'INDEX', DECODE (SUBSTR (object_name, 1, 5),
'SYS_C', 'SYS_C', object_name),
'LOB', DECODE (SUBSTR (object_name, 1, 7),
'SYS_LOB', 'SYS_LOB', object_name),
object_name)
FROM user_objects
GROUP BY object_type
ORDER BY object_type;
PROMPT SUMMARY OF EXTRANEOUS OBJECTS IN LOCAL SCHEMA
SELECT object_type, COUNT (*)
FROM
SELECT object_type,
DECODE (object_type,
'INDEX', DECODE (SUBSTR (object_name, 1, 5),
'SYS_C', 'SYS_C', object_name),
'LOB', DECODE (SUBSTR (object_name, 1, 7),
'SYS_LOB', 'SYS_LOB', object_name),
object_name)
FROM user_objects
WHERE object_type != 'DATABASE LINK'
OR object_name NOT LIKE 'REM_SCHEMA.%'
MINUS
SELECT object_type,
DECODE (object_type,
'INDEX', DECODE (SUBSTR (object_name, 1, 5),
'SYS_C', 'SYS_C', object_name),
'LOB', DECODE (SUBSTR (object_name, 1, 7),
'SYS_LOB', 'SYS_LOB', object_name),
object_name)
FROM user_objects@rem_schema
GROUP BY object_type
ORDER BY object_type;
PROMPT OBJECTS MISSING FROM LOCAL SCHEMA
SELECT object_type,
DECODE (object_type,
'INDEX', DECODE (SUBSTR (object_name, 1, 5),
'SYS_C', 'SYS_C', object_name),
'LOB', DECODE (SUBSTR (object_name, 1, 7),
'SYS_LOB', 'SYS_LOB', object_name),
object_name) object_name
FROM user_objects@rem_schema
MINUS
SELECT object_type,
DECODE (object_type,
'INDEX', DECODE (SUBSTR (object_name, 1, 5),
'SYS_C', 'SYS_C', object_name),
'LOB', DECODE (SUBSTR (object_name, 1, 7),
'SYS_LOB', 'SYS_LOB', object_name),
object_name) object_name
FROM user_objects
ORDER BY object_type, object_name;
PROMPT EXTRANEOUS OBJECTS IN LOCAL SCHEMA
SELECT object_type,
DECODE (object_type,
'INDEX', DECODE (SUBSTR (object_name, 1, 5),
'SYS_C', 'SYS_C', object_name),
'LOB', DECODE (SUBSTR (object_name, 1, 7),
'SYS_LOB', 'SYS_LOB', object_name),
object_name) object_name
FROM user_objects
WHERE object_type != 'DATABASE LINK'
OR object_name NOT LIKE 'REM_SCHEMA.%'
MINUS
SELECT object_type,
DECODE (object_type,
'INDEX', DECODE (SUBSTR (object_name, 1, 5),
'SYS_C', 'SYS_C', object_name),
'LOB', DECODE (SUBSTR (object_name, 1, 7),
'SYS_LOB', 'SYS_LOB', object_name),
object_name) object_name
FROM user_objects@rem_schema
ORDER BY object_type, object_name;
PROMPT OBJECTS IN LOCAL SCHEMA THAT ARE NOT VALID
SELECT object_name, object_type, status
FROM user_objects
WHERE status != 'VALID'
ORDER BY object_name, object_type;
REM Table differences
REM =================
PROMPT TABLE COLUMNS MISSING FROM ONE SCHEMA
PROMPT (NOTE THAT THIS REPORT DOES NOT LIST DISCREPENCIES IN COLUMN ORDER)
SELECT table_name, column_name, 'Local' "MISSING IN SCHEMA"
FROM user_tab_columns@rem_schema
WHERE table_name IN
SELECT table_name
FROM user_tables
MINUS
SELECT table_name, column_name, 'Local' "MISSING IN SCHEMA"
FROM user_tab_columns
UNION ALL
SELECT table_name, column_name, 'Remote' "MISSING IN SCHEMA"
FROM user_tab_columns
WHERE table_name IN
SELECT table_name
FROM user_tables@rem_schema
MINUS
SELECT table_name, column_name, 'Remote' "MISSING IN SCHEMA"
FROM user_tab_columns@rem_schema
ORDER BY 1, 2;
COL schema FORMAT a15
COL nullable FORMAT a8
COL data_type FORMAT a9
COL data_length FORMAT 9999 HEADING LENGTH
COL data_precision FORMAT 9999 HEADING PRECISION
COL data_scale FORMAT 9999 HEADING SCALE
COL default_length FORMAT 9999 HEADING LENGTH_OF_DEFAULT_VALUE
PROMPT DATATYPE DISCREPENCIES FOR TABLE COLUMNS THAT EXIST IN BOTH SCHEMAS
SELECT table_name, column_name, 'Remote' schema,
nullable, data_type, data_length, data_precision, data_scale,
default_length
FROM user_tab_columns@rem_schema
WHERE (table_name, column_name) IN
SELECT table_name, column_name
FROM user_tab_columns
MINUS
SELECT table_name, column_name, 'Remote' schema,
nullable, data_type, data_length, data_precision, data_scale,
default_length
FROM user_tab_columns
UNION ALL
SELECT table_name, column_name, 'Local' schema,
nullable, data_type, data_length, data_precision, data_scale,
default_length
FROM user_tab_columns
WHERE (table_name, column_name) IN
SELECT table_name, column_name
FROM user_tab_columns@rem_schema
MINUS
SELECT table_name, column_name, 'Local' schema,
nullable, data_type, data_length, data_precision, data_scale,
default_length
FROM user_tab_columns@rem_schema
ORDER BY 1, 2, 3;
REM Index differences
REM =================
COL column_position FORMAT 999 HEADING ORDER
PROMPT INDEX DISCREPENCIES FOR INDEXES THAT EXIST IN BOTH SCHEMAS
SELECT A.index_name, 'Remote' schema, A.uniqueness, A.table_name,
B.column_name, B.column_position
FROM user_indexes@rem_schema A, user_ind_columns@rem_schema B
WHERE A.index_name IN
SELECT index_name
FROM user_indexes
AND B.index_name = A.index_name
AND B.table_name = A.table_name
MINUS
SELECT A.index_name, 'Remote' schema, A.uniqueness, A.table_name,
B.column_name, B.column_position
FROM user_indexes A, user_ind_columns B
WHERE B.index_name = A.index_name
AND B.table_name = A.table_name
UNION ALL
SELECT A.index_name, 'Local' schema, A.uniqueness, A.table_name,
B.column_name, B.column_position
FROM user_indexes A, user_ind_columns B
WHERE A.index_name IN
SELECT index_name
FROM user_indexes@rem_schema
AND B.index_name = A.index_name
AND B.table_name = A.table_name
MINUS
SELECT A.index_name, 'Local' schema, A.uniqueness, A.table_name,
B.column_name, B.column_position
FROM user_indexes@rem_schema A, user_ind_columns@rem_schema B
WHERE B.index_name = A.index_name
AND B.table_name = A.table_name
ORDER BY 1, 2, 6;
REM Constraint differences
REM ======================
PROMPT CONSTRAINT DISCREPENCIES FOR TABLES THAT EXIST IN BOTH SCHEMAS
SET FEEDBACK OFF
CREATE TABLE temp_schema_compare
database NUMBER(1),
object_name VARCHAR2(30),
object_text VARCHAR2(2000),
hash_value NUMBER
DECLARE
CURSOR c1 IS
SELECT constraint_name, search_condition
FROM user_constraints
WHERE search_condition IS NOT NULL;
CURSOR c2 IS
SELECT constraint_name, search_condition
FROM user_constraints@rem_schema
WHERE search_condition IS NOT NULL;
v_constraint_name VARCHAR2(30);
v_search_condition VARCHAR2(32767);
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO v_constraint_name, v_search_condition;
EXIT WHEN c1%NOTFOUND;
v_search_condition := SUBSTR (v_search_condition, 1, 2000);
INSERT INTO temp_schema_compare
database, object_name, object_text
VALUES
1, v_constraint_name, v_search_condition
END LOOP;
CLOSE c1;
OPEN c2;
LOOP
FETCH c2 INTO v_constraint_name, v_search_condition;
EXIT WHEN c2%NOTFOUND;
v_search_condition := SUBSTR (v_search_condition, 1, 2000);
INSERT INTO temp_schema_compare
database, object_name, object_text
VALUES
2, v_constraint_name, v_search_condition
END LOOP;
CLOSE c2;
COMMIT;
END;
SET FEEDBACK 1
SELECT REPLACE (TRANSLATE (A.constraint_name,'012345678','999999999'),
'9', NULL) constraint_name,
'Remote' schema, A.constraint_type, A.table_name,
A.r_constraint_name, A.delete_rule, A.status, B.object_text
FROM user_constraints@rem_schema A, temp_schema_compare B
WHERE A.table_name IN
SELECT table_name
FROM user_tables
AND B.database (+) = 2
AND B.object_name (+) = A.constraint_name
MINUS
SELECT REPLACE (TRANSLATE (A.constraint_name,'012345678','999999999'),
'9', NULL) constraint_name,
'Remote' schema, A.constraint_type, A.table_name,
A.r_constraint_name, A.delete_rule, A.status, B.object_text
FROM user_constraints A, temp_schema_compare B
WHERE B.database (+) = 1
AND B.object_name (+) = A.constraint_name
UNION ALL
SELECT REPLACE (TRANSLATE (A.constraint_name,'012345678','999999999'),
'9', NULL) constraint_name,
'Local' schema, A.constraint_type, A.table_name,
A.r_constraint_name, A.delete_rule, A.status, B.object_text
FROM user_constraints A, temp_schema_compare B
WHERE A.table_name IN
SELECT table_name
FROM user_tables@rem_schema
AND B.database (+) = 1
AND B.object_name (+) = A.constraint_name
MINUS
SELECT REPLACE (TRANSLATE (A.constraint_name,'012345678','999999999'),
'9', NULL) constraint_name,
'Local' schema, A.constraint_type, A.table_name,
A.r_constraint_name, A.delete_rule, A.status, B.object_text
FROM user_constraints@rem_schema A, temp_schema_compare B
WHERE B.database (+) = 2
AND B.object_name (+) = A.constraint_name
ORDER BY 1, 4, 2;
REM Database link differences
REM =========================
PROMPT DATABASE LINK DISCREPENCIES
COL db_link FORMAT a40
SELECT db_link, 'Remote' schema, username, host
FROM user_db_links@rem_schema
MINUS
SELECT db_link, 'Remote' schema, username, host
FROM user_db_links
UNION ALL
SELECT db_link, 'Local' schema, username, host
FROM user_db_links
WHERE db_link NOT LIKE 'REM_SCHEMA.%'
MINUS
SELECT db_link, 'Local' schema, username, host
FROM user_db_links@rem_schema
ORDER BY 1, 2;
REM Sequence differences
REM ====================
PROMPT SEQUENCE DISCREPENCIES
SELECT sequence_name, 'Remote' schema, min_value, max_value,
increment_by, cycle_flag, order_flag, cache_size
FROM user_sequences@rem_schema
MINUS
SELECT sequence_name, 'Remote' schema, min_value, max_value,
increment_by, cycle_flag, order_flag, cache_size
FROM user_sequences
UNION ALL
SELECT sequence_name, 'Local' schema, min_value, max_value,
increment_by, cycle_flag, order_flag, cache_size
FROM user_sequences
MINUS
SELECT sequence_name, 'Local' schema, min_value, max_value,
increment_by, cycle_flag, order_flag, cache_size
FROM user_sequences@rem_schema
ORDER BY 1, 2;
REM Private synonym differences
REM ===========================
PROMPT PRIVATE SYNONYM DISCREPENCIES
SELECT synonym_name, 'Remote' schema, table_owner, table_name, db_link
FROM user_synonyms@rem_schema
MINUS
SELECT synonym_name, 'Remote' schema, table_owner, table_name, db_link
FROM user_synonyms
UNION ALL
SELECT synonym_name, 'Local' schema, table_owner, table_name, db_link
FROM user_synonyms
MINUS
SELECT synonym_name, 'Local' schema, table_owner, table_name, db_link
FROM user_synonyms@rem_schema
ORDER BY 1, 2;
REM PL/SQL differences
REM ==================
PROMPT SOURCE CODE DISCREPENCIES FOR PACKAGES, PROCEDURES, AND FUNCTIONS
PROMPT THAT EXIST IN BOTH SCHEMAS
SELECT name, type, COUNT (*) discrepencies
FROM
SELECT name, type, line, text
FROM user_source@rem_schema
WHERE (name, type) IN
SELECT object_name, object_type
FROM user_objects
MINUS
SELECT name, type, line, text
FROM user_source
UNION ALL
SELECT name, type, line, text
FROM user_source
WHERE (name, type) IN
SELECT object_name, object_type
FROM user_objects@rem_schema
MINUS
SELECT name, type, line, text
FROM user_source@rem_schema
GROUP BY name, type
ORDER BY name, type;
PROMPT SOURCE CODE DISCREPENCIES FOR PACKAGES, PROCEDURES, AND FUNCTIONS
PROMPT THAT EXIST IN BOTH SCHEMAS (CASE INSENSITIVE COMPARISON)
SELECT name, type, COUNT (*) discrepencies
FROM
SELECT name, type, line, UPPER (text)
FROM user_source@rem_schema
WHERE (name, type) IN
SELECT object_name, object_type
FROM user_objects
MINUS
SELECT name, type, line, UPPER (text)
FROM user_source
UNION ALL
SELECT name, type, line, UPPER (text)
FROM user_source
WHERE (name, type) IN
SELECT object_name, object_type
FROM user_objects@rem_schema
MINUS
SELECT name, type, line, UPPER (text)
FROM user_source@rem_schema
GROUP BY name, type
ORDER BY name, type;
REM Trigger differences
REM ===================
PROMPT TRIGGER DISCREPENCIES
SET FEEDBACK OFF
TRUNCATE TABLE temp_schema_compare;
DECLARE
CURSOR c1 IS
SELECT trigger_name, trigger_body
FROM user_triggers;
CURSOR c2 IS
SELECT trigger_name, trigger_body
FROM user_triggers@rem_schema;
v_trigger_name VARCHAR2(30);
v_trigger_body VARCHAR2(32767);
v_hash_value NUMBER;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO v_trigger_name, v_trigger_body;
EXIT WHEN c1%NOTFOUND;
v_trigger_body := REPLACE (v_trigger_body, ' ', NULL);
v_trigger_body := REPLACE (v_trigger_body, CHR(9), NULL);
v_trigger_body := REPLACE (v_trigger_body, CHR(10), NULL);
v_trigger_body := REPLACE (v_trigger_body, CHR(13), NULL);
v_trigger_body := UPPER (v_trigger_body);
v_hash_value := dbms_utility.get_hash_value (v_trigger_body, 1, 65536);
INSERT INTO temp_schema_compare (database, object_name, hash_value)
VALUES (1, v_trigger_name, v_hash_value);
END LOOP;
CLOSE c1;
OPEN c2;
LOOP
FETCH c2 INTO v_trigger_name, v_trigger_body;
EXIT WHEN c2%NOTFOUND;
v_trigger_body := REPLACE (v_trigger_body, ' ', NULL);
v_trigger_body := REPLACE (v_trigger_body, CHR(9), NULL);
v_trigger_body := REPLACE (v_trigger_body, CHR(10), NULL);
v_trigger_body := REPLACE (v_trigger_body, CHR(13), NULL);
v_trigger_body := UPPER (v_trigger_body);
v_hash_value := dbms_utility.get_hash_value (v_trigger_body, 1, 65536);
INSERT INTO temp_schema_compare (database, object_name, hash_value)
VALUES (2, v_trigger_name, v_hash_value);
END LOOP;
CLOSE c2;
END;
SET FEEDBACK 1
SELECT A.trigger_name, 'Local' schema, A.trigger_type,
A.triggering_event, A.table_name, SUBSTR (A.referencing_names, 1, 30)
referencing_names, SUBSTR (A.when_clause, 1, 30) when_clause,
A.status, B.hash_value
FROM user_triggers A, temp_schema_compare B
WHERE B.object_name (+) = A.trigger_name
AND B.database (+) = 1
AND A.table_name IN
SELECT table_name
FROM user_tables@rem_schema
MINUS
SELECT A.trigger_name, 'Local' schema, A.trigger_type,
A.triggering_event, A.table_name, SUBSTR (A.referencing_names, 1, 30)
referencing_names, SUBSTR (A.when_clause, 1, 30) when_clause,
A.status, B.hash_value
FROM user_triggers@rem_schema A, temp_schema_compare B
WHERE B.object_name (+) = A.trigger_name
AND B.database (+) = 2
UNION ALL
SELECT A.trigger_name, 'Remote' schema, A.trigger_type,
A.triggering_event, A.table_name, SUBSTR (A.referencing_names, 1, 30)
referencing_names, SUBSTR (A.when_clause, 1, 30) when_clause,
A.status, B.hash_value
FROM user_triggers@rem_schema A, temp_schema_compare B
WHERE B.object_name (+) = A.trigger_name
AND B.database (+) = 2
AND A.table_name IN
SELECT table_name
FROM user_tables
MINUS
SELECT A.trigger_name, 'Remote' schema, A.trigger_type,
A.triggering_event, A.table_name, SUBSTR (A.referencing_names, 1, 30)
referencing_names, SUBSTR (A.when_clause, 1, 30) when_clause,
A.status, B.hash_value
FROM user_triggers A, temp_schema_compare B
WHERE B.object_name (+) = A.trigger_name
AND B.database (+) = 1
ORDER BY 1, 2, 5, 3;
REM View differences
REM ================
PROMPT VIEW DISCREPENCIES
SET FEEDBACK OFF
TRUNCATE TABLE temp_schema_compare;
DECLARE
CURSOR c1 IS
SELECT view_name, text
FROM user_views;
CURSOR c2 IS
SELECT view_name, text
FROM user_views@rem_schema;
v_view_name VARCHAR2(30);
v_text VARCHAR2(32767);
v_hash_value NUMBER;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO v_view_name, v_text;
EXIT WHEN c1%NOTFOUND;
v_text := REPLACE (v_text, ' ', NULL);
v_text := REPLACE (v_text, CHR(9), NULL);
v_text := REPLACE (v_text, CHR(10), NULL);
v_text := REPLACE (v_text, CHR(13), NULL);
v_text := UPPER (v_text);
v_hash_value := dbms_utility.get_hash_value (v_text, 1, 65536);
INSERT INTO temp_schema_compare (database, object_name, hash_value)
VALUES (1, v_view_name, v_hash_value);
END LOOP;
CLOSE c1;
OPEN c2;
LOOP
FETCH c2 INTO v_view_name, v_text;
EXIT WHEN c2%NOTFOUND;
v_text := REPLACE (v_text, ' ', NULL);
v_text := REPLACE (v_text, CHR(9), NULL);
v_text := REPLACE (v_text, CHR(10), NULL);
v_text := REPLACE (v_text, CHR(13), NULL);
v_text := UPPER (v_text);
v_hash_value := dbms_utility.get_hash_value (v_text, 1, 65536);
INSERT INTO temp_schema_compare (database, object_name, hash_value)
VALUES (2, v_view_name, v_hash_value);
END LOOP;
CLOSE c2;
END;
SET FEEDBACK 1
SELECT A.view_name, 'Local' schema, B.hash_value
FROM user_views A, temp_schema_compare B
WHERE B.object_name (+) = A.view_name
AND B.database (+) = 1
AND A.view_name IN
SELECT view_name
FROM user_views@rem_schema
MINUS
SELECT A.view_name, 'Local' schema, B.hash_value
FROM user_views@rem_schema A, temp_schema_compare B
WHERE B.object_name (+) = A.view_name
AND B.database (+) = 2
UNION ALL
SELECT A.view_name, 'Remote' schema, B.hash_value
FROM user_views@rem_schema A, temp_schema_compare B
WHERE B.object_name (+) = A.view_name
AND B.database (+) = 2
AND A.view_name IN
SELECT view_name
FROM user_views
MINUS
SELECT A.view_name, 'Remote' schema, B.hash_value
FROM user_views A, temp_schema_compare B
WHERE B.object_name (+) = A.view_name
AND B.database (+) = 1
ORDER BY 1, 2;
REM Job queue differences
REM =====================
COL what FORMAT a30
COL interval FORMAT a30
PROMPT JOB QUEUE DISCREPENCIES
SELECT what, interval, 'Remote' schema
FROM user_jobs@rem_schema
MINUS
SELECT what, interval, 'Remote' schema
FROM user_jobs
UNION ALL
SELECT what, interval, 'Local' schema
FROM user_jobs
MINUS
SELECT what, interval, 'Local' schema
FROM user_jobs@rem_schema
ORDER BY 1, 2, 3;
REM Privilege differences
REM =====================
PROMPT OBJECT-LEVEL GRANT DISCREPENCIES
SELECT owner, table_name, 'Remote' schema, grantee, privilege, grantable
FROM user_tab_privs@rem_schema
WHERE (owner, table_name) IN
SELECT owner, object_name
FROM all_objects
MINUS
SELECT owner, table_name, 'Remote' schema, grantee, privilege, grantable
FROM user_tab_privs
UNION ALL
SELECT owner, table_name, 'Local' schema, grantee, privilege, grantable
FROM user_tab_privs
WHERE (owner, table_name) IN
SELECT owner, object_name
FROM all_objects@rem_schema
MINUS
SELECT owner, table_name, 'Local' schema, grantee, privilege, grantable
FROM user_tab_privs@rem_schema
ORDER BY 1, 2, 3;
PROMPT SYSTEM PRIVILEGE DISCREPENCIES
SELECT privilege, 'Remote' schema, admin_option
FROM user_sys_privs@rem_schema
MINUS
SELECT privilege, 'Remote' schema, admin_option
FROM user_sys_privs
UNION ALL
SELECT privilege, 'Local' schema, admin_option
FROM user_sys_privs
MINUS
SELECT privilege, 'Local' schema, admin_option
FROM user_sys_privs@rem_schema
ORDER BY 1, 2;
PROMPT ROLE PRIVILEGE DISCREPENCIES
SELECT granted_role, 'Remote' schema, admin_option, default_role, os_granted
FROM user_role_privs@rem_schema
MINUS
SELECT granted_role, 'Remote' schema, admin_option, default_role, os_granted
FROM user_role_privs
UNION ALL
SELECT granted_role, 'Local' schema, admin_option, default_role, os_granted
FROM user_role_privs
MINUS
SELECT granted_role, 'Local' schema, admin_option, default_role, os_granted
FROM user_role_privs@rem_schema
ORDER BY 1, 2;
SPOOL OFF
SET TERMOUT ON
PROMPT
PROMPT Report output written to &report
SET FEEDBACK OFF
DROP TABLE temp_schema_compare;
DROP DATABASE LINK rem_schema;
SET FEEDBACK 6
SET PAGESIZE 20
SET LINESIZE 80 -
How to compare two PLSQL tables dynamically.
Hi,
Can you any body help for the following scenario,
I have two PLSQLtables with same structure ,Each PLSQL table contains more than 100 columns.
Now I want to compare content of the two PLSQL tables column wise.
I Knew allready one method like below
FOR I IN 1..100
LOOP
IF PLSQL_1_TAB(I).ACCT_NO = PLSQL_2_TAB(I).ACCT_NO THEN
INSERT INTO …....
END IF;
END LOOP;
is there any method to compare two PLSQL tables dynamically
Edited by: RAVI KUMAR.T.V. on May 5, 2011 11:51 PMHi Saubhik,
Thanks for your reply..
See the below code..
DECLARE
CURSOR cur_emp IS
SELECT *
FROM emp
WHERE job = 'MANAGER';
TYPE typ1 IS TABLE OF emp%ROWTYPE INDEX BY BINARY_INTEGER;
v_pl_old typ1;
v_pl_new typ1;
BEGIN
OPEN cur_emp;
FETCH cur_emp INTO v_pl_old(1);
CLOSE cur_emp;
UPDATE emp SET comm = comm+1000 WHERE hiredate < '01-MAY-1981' AND job = 'MANAGER';
COMMIT;
OPEN cur_emp;
FETCH cur_emp INTO v_pl_new(1);
CLOSE cur_emp;
IF v_pl_old(1) = v_pl_new(1) THEN
DBMS_OUTPUT.PUT_LINE('Latest comm not yet Updated');
ELSE
DBMS_OUTPUT.PUT_LINE('Latest comm Updated');
END IF;
END;
When the above code is executed iam getting the following error :
ORA-06550: line 19, column 19: PLS-00306: wrong number or types of arguments in call to '='
ORA-06550: line 19, column 4: PL/SQL: Statement ignored
Here in the example I have taken the standard EMP table, but
actually, Iam having a bigger table with 90 columns of different datatypes,
in which some of the columns gets updated after some UPDATE statements executed based on some conditions.
Now, my requirement is to compare the values of each and every column in the table before and after the execution of the UPDATE statements,
and to insert the modified values only along with the primary key column value into in a new table of similar structure.
If I write the code (to compare the values of each and every column in the table, and if the value is modified then insert that value along with the primary key value into a different talbe) then as the table is having many columns (90), the code becomes lengthy..
Is there any alternative method which does the same with shorter code.
Can you please give me an idea/sol. to meet my requirement.
Thanks..
Edited by: RAVI KUMAR.T.V. on May 9, 2011 2:43 AM -
Comparing two rows field by field through a loop
Hi all,
I've got a tricky issue:
There are two tables (almost) identically designed;
In the first one there are lets say some new data and in the 2nd one there is data to be hold & adjusted;
I built up a third table, which contains the meta informations about the two other tables (i.e. it describes the tables, so for each field of these tables, there is the field name, field type, primary key marker, etc.);
The challenge now is, how can I compare two rows (of the same primary key) field by field and get out the differences (and adjusting the target table row) using PL/SQL procedures/functions.
I thought a create a cursor over the 3rd table and call functions to get the fields out (given by the field name of the cursor), compare the two fields and return if it's equal or different...
As I've seen, there is now direct way to replace a field name in a statement - but how to resolve this with a cool workaround?
In addition, there are about 120 pairs of such tables, to be compared in the same way - so I decided to prevent creating hard coded design for the software.
Even the selection of a pair of rows from the two tables should be parameterized, 'cause the primary keys are of course different in the 120 table pairs.
Any hints or suggestions?
Thanks in advance & regards,
PeterHi Peter,
I am very far from being an expert in Oracle but, everything I've read so far strongly suggests that PL/SQL is often the fastest among the customized solutions (beating even compiled C code). The reason - from what I've understood - is that PL/SQL is part of the Oracle kernel/engine, other languages simply aren't.
I suggest you do your own research to confirm what I've just said above.
On a completely different note, when I first read your post, I started writing a reply and decided to discard it because, I figured you probably would find it too far off your original thoughts. However, then you wrote:
>
There are some reasons to prevent hard coding, but it may be possible to generate the PL/SQL-code for each pair of tables by an external program.
>
This is exactly what I was mentioning in the post I ended up discarding. The basic step by step process I was going to mention is as follows:
STEP 1: If possible, write one PL/SQL program that does the job properly for one set of tables. Test it thoroughly and identify potential differences in the process if it had to be applied against other tables. Make it as generic as reasonably possible, that is, keeping the code as simple as possible.
STEP 2: turn the working code of step 1 into a template (usually replacing table names, columns, etc by some token that would not be a valid name).
STEP 3: generate a list of the tables and their corresponding columns you need to process. This list may need to be massaged a little to become the generating seed of 120 programs (or so based on what you've said).
STEP 4: if you don't know Perl or AWK then (don't be alarmed...) download AWK (not Perl) and learn it... you can learn the thing in a couple days (maybe even less). It is a very simple and straightforward text processing language, I know non progammers that learned enough in one day to do useful things with it. Using AWK you can easily generate the 120 programs you need from a working template in very little time (a few hours after you've become proficient). By the way, there is AWK, GAWK, NAWK, all pretty much the same thing and all free. The standard manual for AWK is the one written by the authors Aho, Weinberger and Kernigan, about 100 small pages, it's an easy read and no programmer should be without it :) (better than American Express!)
What you've described sounds just like the thing to use AWK for. I once used AWK to generate 27,000 (that's 27 thousand) lines of COBOL code, debugged and fully tested in 2 days! (testing was automated using AWK too!) It would have taken much longer to just type all that code.
Anyway, I hope that gives you something to think about and be of some help.
John. -
Two "cursors" when in tablet mode
X61 tablet, Windows 7, RC1, 64 bit. , pdfannotator, onenote, office
When using the the tablet in tablet mode (screen folded down), I often will get two cursors on the screen when the pen is near or on it. This happens in various application software, but usually begins after using the eraser, or the flyout keyboard and tablet input menu.
The extra cursor appears above, and to the right of the actual cursor. Actual cursor being a pen tip "dot" while the extra cursor is a random symbol, ranging from another offset dot, to a very dark right click ring, to a very dark hourglass, to an i-beam shaped bar. It happens immediately when using grahl's pdf annotator, but has showed up in other programs as well including onenote, after using the flyout input panel in word, and a number of other programs.
I'm certain it has something to do with the tablet multitouch drivers, escpecially since the drivers for 7 seem to be a wacom dual-touch driver not designed specifically for the X61. Anyone else run into this trouble and come across a solution?This is what Microsoft Support told me to do, and it worked, but I am stuck with a boring standard mouse cursor in Windows (no special Tablet PC cursors - for right click, etc.)
Step 1:
1. Open Local Group Policy Editor:Run... gpedit.msc
2. Navigate to User Configuration - Administrative Templates - Windows Components - Tablet PC - Cursors
3. Enable the Turn off pen feedback setting.
Step 2:
Go to Control Panel. Double click on Mouse. Find "Mouse Properties"
Go to "Pointer Options". Put a check mark in the "Display Pointer trails"
Slide the bar over to "short". Apply the changes and then restart PDF Annotator.
I'm awaiting Microsoft's reply as to whether there is some way to keep my original cursors without having the PDF Annotator problem. -
Do you know about any possible Java bugs with JDK update?
In my case, my code stopped working.
Here is what I have. There are two similar objects, but Object 1 has key, and Object 2 (same as Object 1) has no key. I need to compare both, and if they are equal, I need Object 1 to assign key to Object 2.
It worked before. How I can get around.
Please help me if you can.
Respectfully,
AlexLet me change the question:
"Can we compare two objects one with key and another one without key? How? -
Compare two Java Objects without Comparable / Comparator
Hi Friends,
I would like to compare two java objects (lots o attributes) without using Comparable / Comparator.
Any suggestion/sample code would be helpful.
Thanks,
SachinI suppose you could design another feature to compare Objects... but that would involve a design process, so asking for sample code is definitely premature. And as EJP says, what would be the point?
At least that's what I would answer if this was one of those stupid interview questions. -
How can I compare two collections at the same time? (View two grid views)
I have two collections containing some of the same images. (My Nikon D70 did not put an end-of-file on some images. I recovered them into a different collection.) Now I want to display both collections side-by-side in grid view. I will select those images in the "recovered" collection that correspond to the bad images in the "main" collection, add the ratings etc, and move just these to another collection.
It is extremely frustrating to have to bounce back and forth between collections, remembering each image one by one and selecting it in the "recovered" collection. (The image names are not preserved in the "recovered" collection -- I have to go by what the image looks like.)
LightRoom allows me to compare photos in the compare view. I want to compare collections in two grid views.CaptureTheLight,
you have ran into a situation when you have to compare two sets of images and now you're wondering how come Lightroom doesn't have such "obviously necessary" functionality? But you have to admit it, this is not such a common situation in a photographer's workflow recovers broken files and tries to compare them against themselves. I think it's a pretty specific feature you need. Still, Lightroom has enough powerful tools for editing and sorting images.
For example...
You could just put them all - "main" and "recovered" - into a single collection or into the Quick Collection. Label the entire "recovered" collection with, say, red and sort by capture time. Now you'll have everything side by side, ordered chronologically. The "recovered" images will stay next to the "main" images since their capture time will be the same, and they will also stand out since they have the red label.
Make the thumbnails bigger and set up the grid view so it tints the thumbnail cell are tinted with the label color. Now, you can go quickly through them visually checking labeled vs unlabeled. -
How can i compare two excel files with different no. of records.
Hi
I am on to a small project that involves us to compare two excel files. i am able to do it but am struck up at a point. When i compare 2 different .csv files with different no. of lines i am only able to compare upto a point till when the number of lines is same in both the files.
Eg. if source file has 8 lines and target file has 12 lines. The difference is displayed only till 8 lines and the remaining 4 lines in source lines are not shown.
Can you help me in displaying those extra 4 lines in source file. I am attaching my code snippet below..
while (((strLine = br.readLine()) != null) && ((strLine1 = br1.readLine())) != null)
String delims = "[;,\t,,,|]";
String[] tokens = strLine.split(delims);
String[] tokens1 = strLine1.split(delims);
if (tokens.length > tokens1.length)
for (int i = 0; i < tokens.length; i++) {
try {
if (!tokens.equals(tokens1[i])) {
System.out.println(tokens[i] + "<----->" + tokens1[i]);
out.write(sno + " \t" + lineNo1 + " \t\t" + tokens[i] + "\t\t\t\t" + tokens1[i]);
out.println();
sno++;
} catch (Exception exception)
out.write(sno + " \t" + lineNo1 + " \t\t" + tokens[i] + "\t\t\t\t" + "");
out.println();
Thanks & RegardsA CSV file is not an Excel file.
But apart from that your logic makes no sense.
If the 2 files are of different sizes the files are different by definition, so further comparison isn't needed, you're done.
If you want to compare individual records, you need to compare all records from one file with all records from the other, unless the order of records is important in which case your current system might work.
That system however is overly complicated for comparing CSV files.
As you assume a single record per line, and if one can assume those records to have identical layout (so no leading or trailing whitespace in or between columns in one file that's not in the other) comparing records is simply a matter of comparing the entire lines. -
I am working on procedure, Please give ideas where i can develop this logic more meaning and easy
the logic is as follows
Table1 is having same Id's ABC having same seq number 100 as per legacy data (This is wrong entry in legacy data)
ID -- Seqnum
ABC -- 100
ABC -- 100
I created a table2 where it will have max seqnum from legacy for this ID's for example ABC
ID -- Max seqnum
ABC --500
In my procedure I will have two cursors
First cursor will be have Table1 detail
Second Cursor will have Table2 Details
In above ex the table will have the first record should be unchanged i.e.,
ABC -- 100 --100
but second record will change to
ABC -- 100 -- 501(This next value of the max seq number from table 2/Cursor 2)
I have to create third column which will hold the next seqnumber for that ID ABC
I should load both records changing the seqnumber so I will not have any duplicate records for same ID.
So final records will look like
ID Seq# Final_Seq#
ABC -- 100 -- 100
ABC -- 100 -- 501
Thanks in advance.Adjusted accordingly to the message above
with
data_tab as
(select 'ABC' id,100 seq from dual union all
select 'ABC',100 from dual union all
select 'ABC',100 from dual union all
select 'BCD',110 from dual union all
select 'CDE',120 from dual union all
select 'CDE',120 from dual union all
select 'DEF',130 from dual union all
select 'EFG',140 from dual union all
select 'EFG',140 from dual union all
select 'EFG',140 from dual union all
select 'EFG',240 from dual union all
select 'EFG',240 from dual union all
select 'FGH',150 from dual
max_nums as
(select 'ABC' id,200 max_num from dual union all
select 'BCD',300 from dual union all
select 'CDE',400 from dual union all
select 'DEF',500 from dual union all
-- select 'EFG',600 from dual union all
select 'FGH',700 from dual
select d.id,d.seq,row_number() over (partition by d.id,d.seq order by null) rn,m.max_num,
case when row_number() over (partition by d.id,d.seq order by null) = 1
then d.seq
else nvl(m.max_num,d.seq) + row_number() over (partition by d.id,d.seq order by null) - 1
end new_seq
from data_tab d,
max_nums m
where d.id = m.id(+)
ID
SEQ
RN
MAX_NUM
NEW_SEQ
ABC
100
1
200
100
ABC
100
2
200
201
ABC
100
3
200
202
BCD
110
1
300
110
CDE
120
1
400
120
CDE
120
2
400
401
DEF
130
1
500
130
EFG
140
1
140
EFG
140
2
141
EFG
140
3
142
EFG
240
1
240
EFG
240
2
241
FGH
150
1
700
150 -
Hi All,
Two cursors in the same procedure will slows down the execution ?. Please can any one suggest one this.I aggree with Sundar, you might be able to update this without using a cursor. My general understanding is to avoid using cursor as much as possible for performance reasons, if you are doing a lot of inserts/updates etc. If you are doing lot of updates and you must have to iterate through a loop due to some reason then try to use bulk processing (use bulk inserts, updates, one sql query to access data from database to avoid conext switching etc.).
-
Functinality to compare two material price with reference to BOM in CO
Hi All,
Is there is any functionality in Controlling which can compare the costing for two FERT materials.
or
is there is any functionality where we can compare two material price with reference to BOM in controlling
Please help me to compare the material price with reference to BOM
Regards
nanduHi,
You can use this report to compare two itemizations. The report compares the characteristics item number, item category, cost element, resource, material, cost center, plant/work center, cost center/activity type, operation number, BOM item, assembly indicator, and cost component.
You can access this report as follows:
Accounting ® Controlling ® Product Cost Controlling ® Product Cost Planning ® Material Costing ® Cost Estimate with Quantity Structure or Cost Estimate Without Quantity Structure ® Compare
or
Accounting ® Controlling ® Product Cost Controlling ® Product Cost Planning ® Information System ® Object Comparisons ® For Material ® Itemization Comparison.
For Detail Please reffer following link:
http://help.sap.com/saphelp_46c/helpdata/en/56/abd108f1a611d28a950000e8214595/content.htm
Thanks and Regards
Binoj M D -
Hi
i used the Build JDEVADF_11.1.1.4.0
I want to make compare validation between two input text Are equal or not . same Thing when i create new email i must enter the password and re enter password if not equal he give me messageHi,
for a validation String, you can put autosubmit=true and in the valuechangeListener make the comparation.
How to compare two Strings in java? http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java -
How to compare two excel reports and find the difference in BI Publisher
Hi All,
I have a requirement that needs to compare two excel reports in XML Publisher 5.6.2. or BI publisher 10.1.3.4
If anybody has an idea about this pls help us.
Thanks,Since our customer wants to have this comparison only with BI reports....here is the scenario how the comparison should be..
Now,we have a parameters called Customer name and version id. Version id list will be refreshed based on the customer selection.
User can generate the report based on the selected customer name and version id. These data are fetch from the oracle database and we are using Data Template in the BI Publisher.
Now the requirement is customer wants to compare two version id data. for example, v1.2 and v1.3
Now they wanna to see both the reports while generating in the same work sheet, like, v1.2report should display in the left side and the v1.3report has to display in the right hand side of the same work sheet.
Now...If there is any addition happened in v1.3 report,then that cell/data should display as a green color in that report.
If any deletion happened in v1.3report then that should be in the red color.
If any modification happened in v1.3 then that should be in the yellow color.
If there is no difference then that should display as it is.
the thing is that, the both the reports (v1.2 and v1.3)should display side by side in the same worksheet with the format and everything........only the difference should be highlighted.
Template is same for both the reports..
To display the data for both versions i think i can generate the template side by side of both in the same worksheet.
Now, My question is how to find the difference of data in the RTF Template for both the versions
Can anybody assist me?
Thanks,
Edited by: user753355 on Jun 9, 2009 12:03 AM
Edited by: user753355 on Jun 9, 2009 12:06 AM
Edited by: user753355 on Jun 9, 2009 12:16 AM
Edited by: user753355 on Jun 10, 2009 3:59 AM
Maybe you are looking for
-
How do I connect my iPad to a new PC and lose the link to my old PC?
I have purchased very littl music through iTunes, but I have a great many CDs copied to iTunes. I established a good link between my iPad (iOS 7) and my PC. Initially I had iTunes Match but my broadband was too slow. I used the sync over wi-fi connec
-
VLC crash when playing network stream
(gdb) run Starting program: /usr/bin/vlc Got object file from memory but can't read symbols: File truncated. warning: Could not load shared library symbols for linux-vdso.so.1. Do you need "set solib-search-path" or "set sysroot"? [Thread debugging u
-
How do I check what java I have and then how dow I download the newest version?
'''I signed up for wwe.com for my birthday and Christmas present to myself. There were some problems with the how it ran so I had to secure the services of OMNITECH (who I would never recommend to anyone again as I am finding out things have been rem
-
Here is the error: Process: Safari [4602] Path: /Applications/Safari.app/Contents/MacOS/Safari Identifier: com.apple.Safari Version: 5.1.7 (7534.57.7) Build Info: WebBrowser-7534057007000000~2 Code Type: X86
-
Blending images using ps elements 5.0
hi i cant find any tutorials to blend images. please if anyone know how to please help me. i saw few tutorials but they keep talking about layer mask and i dont see it. help me! char.