Compare and test values in two tables
hi everbody, I use oracle 10g
I have a table for large itemsets called L shown below with values
ITEMS CODE
b 1
c 2
d 3
e 4
d:e 5
b:c 6
I generate all candidate combinations firstly 2-sequences for in code field values for that I use below code
select ltrim(replace(sys_connect_by_path(code,','),',',':'),':') comb,level
from L
where level > 1
connect by level =2 ;
some candidate examles generated above code shown belown ( i interest only comb results values )
comb
1:1
1:2
1:3
1:4
1:5
1:6
2:1
2:2
6:1
6:6
I have another table called T2 shown below with some values
TID ITEM CID T_DATE
1 b 1 05.05.1999
1 c 1 05.05.1999
2 e 1 17.05.1999
3 d 2 13.05.1999
4 b 2 19.05.1999
4 c 2 19.05.1999
5 d 2 21.05.1999
6 a 3 07.05.1999
6 b 3 07.05.1999
7 d 3 15.05.1999
7 e 3 15.05.1999
8 b 4 11.05.1999
8 c 4 11.05.1999
9 c 4 16.05.1999
now I want to test every items belong to candidate code generated above with item values of T2 table
in test table T2 is grouped by CID and T_DATE. I want to compare items belong to current code with item of T2 table. if first item(s) in candidate combination is found in T2 table , second item(s) must be found too if there is. but this first and second item(s) together must be found same CID but at different T_DATE belong to that CID. if found, this candidate okey for me.for example we take candidate 3:1. items are d ( code 3 ) and b ( code 1 ) respectively. first item d is searched for CID = 1, it is not found. now we search item d for CID = 2 again , yes it is found in TID=3 row then we look another item b for CID=2 but item b must be found after d row for same CID and at different T_DATE. yes item d is found too for CID=2 after b item at different T_DATE in TID=4 row. that is we wants, is customer ( for example CID 2) buy item b after buying item d same customer at another time as sequence. second example may be candidate 5:6. is customer buy items b and c together ( for code 6) after at another time buying items d and e ( code 5 ) together by same customer
NOTE : I use code field sequence values for pointer of items. items may be used directly on generating candidate process and used comparing process with T2 table
thanks for smart idea....
In addition I would suggest you read this:
http://forums.oracle.com/forums/help.jspa
and learn to use the tags to format the parts of the post that belong in fixed format.
Similar Messages
-
Oracle SP for comparing 80 column values across 8 table pairs in 2 diff DBs
Hi All,
I have an Oracle SP for comparing 80 column values across 8 table pairs in 2 diff DBs.
However, it is taking hell lot of time around 6hours to process 10,000 records.
Can anyone suggest how to fine-tune this?
Thanks guys.Tables prefixed with X are the temp tables to store data of DB-A.
The report will be originally based on DB-B, so DB Links will not be required for @PROD1.WORLD tables.
This is a test region, so I have pointed to @PROD1.WORLD to test with Prod Data.
SEC_COMPARE_CONFIG is the config table containing the table_name to be reported, corresponding temp tables to store the data and the columns on which it is to be reported.
There are in total 8 tables- 90 rows and 8 temp tables.
SPOKE_TO_HUB_SEC_MTCH_TBL records the securities on which it is to be reported.
HIST_DATA_COMPARE_TBL is the final results table.
Here is the entire code:
CREATE OR REPLACE PACKAGE SECURITY_COMPARE AS
PROCEDURE PROCESS_RECORDS (IN_EFFECTIVE_DATE IN DATE,
IN_PRIMARY_ASSET_ID IN VARCHAR2 DEFAULT NULL);
PROCEDURE IDENTIFY_SECURITIES ( P_EFFECTIVE_DATE IN DATE,
P_PRIMARY_ASSET_ID IN VARCHAR2 DEFAULT NULL);
PROCEDURE RETREIVE_RECORDS_FROM_SPOKE;
PROCEDURE COMPARE_RECORDS(p_err_msg OUT VARCHAR2);
PROCEDURE INSERT_DATA_TO_TABLE ( v_target_table VARCHAR2, v_sql_to_run VARCHAR2, v_commit_after NUMBER);
END SECURITY_COMPARE;
CREATE OR REPLACE PACKAGE BODY SECURITY_COMPARE AS
/*Declared String for recording Dynamic SQL's*/
LC_SQL VARCHAR2 (20000);
PROCEDURE PROCESS_RECORDS(IN_EFFECTIVE_DATE IN DATE,
IN_PRIMARY_ASSET_ID IN VARCHAR2 DEFAULT NULL)
AS
L_EFF_DATE DATE;
L_PRIMARY_ASSET_ID VARCHAR2(100);
k_err_msg VARCHAR2(100); --Error message displayed in case of NO discretionary records found.
BEGIN
L_EFF_DATE := IN_EFFECTIVE_DATE;
L_PRIMARY_ASSET_ID := IN_PRIMARY_ASSET_ID;
IDENTIFY_SECURITIES(L_EFF_DATE,L_PRIMARY_ASSET_ID); --Calling the Identify_Securities procedure to identify the securities older by 90 days from report effective date
RETREIVE_RECORDS_FROM_SPOKE(); --Retreiving the historic records from the security tables into temporary tables.
COMPARE_RECORDS(p_err_msg=>k_err_msg); --Compare the records and report the discrepencies into HIST_DATA_COMPARE_TBL table
END PROCESS_RECORDS;
PROCEDURE IDENTIFY_SECURITIES(P_EFFECTIVE_DATE IN DATE,
P_PRIMARY_ASSET_ID IN VARCHAR2 DEFAULT NULL)
AS
P_EFF_DATE DATE; --Effective Date of the report
P_PRIMARY_ID VARCHAR2(100); --Primary AssetID which is used to search based on specific security
v_target_table VARCHAR2(500); --Variable indicating the Target table for inserting the data
v_sql_to_run VARCHAR2(5000); --Variable to store the Dynamic SQL to be executed
v_commit_after NUMBER; --Variable to define after how many records is COMMIT to be done
BEGIN
LC_SQL :='';
P_EFF_DATE := P_EFFECTIVE_DATE;
P_PRIMARY_ID := P_PRIMARY_ASSET_ID;
/*Deleting Old Entries from SPOKE_TO_HUB_SEC_MTCH_TBL table*/
LC_SQL := 'TRUNCATE TABLE SPOKE_TO_HUB_SEC_MTCH_TBL';
EXECUTE IMMEDIATE LC_SQL;
IF(P_PRIMARY_ID is NULL) --In case records do not need to be identified on basis of specific security
THEN
/*Identify Securities older by 90days from report effective date*/
v_target_table := ' SPOKE_TO_HUB_SEC_MTCH_TBL';
v_sql_to_run := 'WITH T AS ('||
' SELECT R.PRIMARY_ASSET_ID PRIMARY_ASSET_ID_R,'||
' R.SECURITY_ALIAS SECURITY_ALIAS_R,'||
' R.LAST_HELD_DATE LAST_HELD_DATE_R,'||
' R.PREV_HELD_DATE PREV_HELD_DATE_R,'||
' Q.PRIMARY_ASSET_ID PRIMARY_ASSET_ID_Q,'||
' Q.SECURITY_ALIAS SECURITY_ALIAS_Q,'||
' COUNT(*) OVER(PARTITION BY Q.PRIMARY_ASSET_ID) CNT'||
' FROM [email protected] R,'||
' [email protected] Q'||
' WHERE SYS_OP_MAP_NONNULL(R.last_held_date) <> '||q'!'FF'!'||
' and ceil(R.last_held_date-to_date('||''''||P_EFF_DATE||''''||')) >= 0'||
' and ceil(R.last_held_date-to_date('||''''||P_EFF_DATE||''''||')) <= 60'||
' and R.PRIMARY_ASSET_ID=Q.PRIMARY_ASSET_ID'||
' )'||
' SELECT PRIMARY_ASSET_ID_R,'||
' SECURITY_ALIAS_R,'||
' LAST_HELD_DATE_R,'||
' PREV_HELD_DATE_R,'||
' PRIMARY_ASSET_ID_Q,'||
' SECURITY_ALIAS_Q'||
' FROM T'||
' WHERE CNT =1';
v_commit_after := 0;
INSERT_DATA_TO_TABLE(v_target_table,v_sql_to_run,v_commit_after);
ELSE
v_target_table := ' SPOKE_TO_HUB_SEC_MTCH_TBL';
v_sql_to_run := 'WITH T AS ('||
' SELECT R.PRIMARY_ASSET_ID PRIMARY_ASSET_ID_R,'||
' R.SECURITY_ALIAS SECURITY_ALIAS_R,'||
' R.LAST_HELD_DATE LAST_HELD_DATE_R,'||
' R.PREV_HELD_DATE PREV_HELD_DATE_R,'||
' Q.PRIMARY_ASSET_ID PRIMARY_ASSET_ID_Q,'||
' Q.SECURITY_ALIAS SECURITY_ALIAS_Q,'||
' COUNT(*) OVER(PARTITION BY Q.PRIMARY_ASSET_ID) CNT'||
' FROM [email protected] R,'||
' [email protected] Q'||
' where R.PRIMARY_ASSET_ID='||''''||P_PRIMARY_ID||''''||
' and R.PRIMARY_ASSET_ID=Q.PRIMARY_ASSET_ID'||
' )'||
' SELECT PRIMARY_ASSET_ID_R,'||
' SECURITY_ALIAS_R,'||
' LAST_HELD_DATE_R,'||
' PREV_HELD_DATE_R,'||
' PRIMARY_ASSET_ID_Q,'||
' SECURITY_ALIAS_Q'||
' FROM T'||
' WHERE CNT =1';
v_commit_after := 0;
INSERT_DATA_TO_TABLE(v_target_table,v_sql_to_run,v_commit_after);
END IF;
LC_SQL := 'TRUNCATE TABLE HIST_DATA_COMPARE_TBL';
EXECUTE IMMEDIATE LC_SQL;
END IDENTIFY_SECURITIES;
PROCEDURE RETREIVE_RECORDS_FROM_SPOKE
AS
v_target_table VARCHAR2(500);
v_sql_to_run VARCHAR2(5000);
v_commit_after NUMBER;
BEGIN
LC_SQL :='';
LC_SQL:= 'TRUNCATE TABLE X_SECMASTER_HISTORY_TBL';
EXECUTE IMMEDIATE LC_SQL;
LC_SQL:= 'TRUNCATE TABLE X_SEC_MASTER_DTL_HIST_TBL';
EXECUTE IMMEDIATE LC_SQL;
LC_SQL:= 'TRUNCATE TABLE X_SECMASTER_DTL_EXT_HST_TBL';
EXECUTE IMMEDIATE LC_SQL;
LC_SQL:= 'TRUNCATE TABLE X_EQUITY_HIST_TBL';
EXECUTE IMMEDIATE LC_SQL;
LC_SQL:= 'TRUNCATE TABLE X_EQUITY_DETAIL_HIST_TBL';
EXECUTE IMMEDIATE LC_SQL;
LC_SQL:= 'TRUNCATE TABLE X_FIXED_INCOME_HIST_TBL';
EXECUTE IMMEDIATE LC_SQL;
LC_SQL:= 'TRUNCATE TABLE X_FIXED_INCOME_DTL_EXT_TBL';
EXECUTE IMMEDIATE LC_SQL;
LC_SQL:= 'TRUNCATE TABLE X_DERIVATIVES_HIST_TBL';
EXECUTE IMMEDIATE LC_SQL;
/*SECMASTER_HISTORY*/
v_target_table := 'X_SECMASTER_HISTORY_TBL';
v_sql_to_run := ' SELECT /*+DRIVING_SITE(K)*/ K.* FROM [email protected] K '||
' INNER JOIN SPOKE_TO_HUB_SEC_MTCH_TBL I'||
' ON K.SECURITY_ALIAS = I.SPOKE_SEC'||
' AND K.SRC_INTFC_INST = 140 '||
' and K.EFFECTIVE_DATE =(SELECT /*+DRIVING_SITE(H)*/ MAX (H.EFFECTIVE_DATE) FROM [email protected] H WHERE'||
' H.SECURITY_ALIAS = K.SECURITY_ALIAS AND H.SRC_INTFC_INST = K.SRC_INTFC_INST)' ;
v_commit_after := 0;
INSERT_DATA_TO_TABLE(v_target_table,v_sql_to_run,v_commit_after);
/*SECURITY_MASTER_DETAIL_HIST*/
v_target_table := 'X_SEC_MASTER_DTL_HIST_TBL';
v_sql_to_run:= ' SELECT /*+DRIVING_SITE(K)*/ K.* FROM [email protected] K '||
' INNER JOIN SPOKE_TO_HUB_SEC_MTCH_TBL I'||
' ON K.SECURITY_ALIAS = I.SPOKE_SEC'||
' AND K.SRC_INTFC_INST = 140 '||
' and K.EFFECTIVE_DATE =(SELECT /*+DRIVING_SITE(H)*/ MAX (H.EFFECTIVE_DATE) FROM [email protected] H WHERE'||
' H.SECURITY_ALIAS = K.SECURITY_ALIAS AND H.SRC_INTFC_INST = K.SRC_INTFC_INST)' ;
v_commit_after := 0;
INSERT_DATA_TO_TABLE(v_target_table,v_sql_to_run,v_commit_after);
/*SECMASTER_DETAIL_EXT_HIST*/
v_target_table := 'X_SECMASTER_DTL_EXT_HST_TBL';
v_sql_to_run:= ' SELECT /*+DRIVING_SITE(K)*/ K.* FROM [email protected] K '||
' INNER JOIN SPOKE_TO_HUB_SEC_MTCH_TBL I'||
' ON K.SECURITY_ALIAS = I.SPOKE_SEC'||
' AND K.SRC_INTFC_INST = 140 '||
' and K.EFFECTIVE_DATE =(SELECT /*+DRIVING_SITE(H)*/ MAX (H.EFFECTIVE_DATE) FROM [email protected] H WHERE'||
' H.SECURITY_ALIAS = K.SECURITY_ALIAS AND H.SRC_INTFC_INST = K.SRC_INTFC_INST)' ;
v_commit_after := 0;
INSERT_DATA_TO_TABLE(v_target_table,v_sql_to_run,v_commit_after);
/*EQUITY_HIST*/
v_target_table := 'X_EQUITY_HIST_TBL';
v_sql_to_run:= ' SELECT /*+DRIVING_SITE(K)*/ K.* FROM [email protected] K '||
' INNER JOIN SPOKE_TO_HUB_SEC_MTCH_TBL I'||
' ON K.SECURITY_ALIAS = I.SPOKE_SEC'||
' AND K.SRC_INTFC_INST = 140 '||
' and K.EFFECTIVE_DATE =(SELECT /*+DRIVING_SITE(H)*/ MAX (H.EFFECTIVE_DATE) FROM [email protected] H WHERE'||
' H.SECURITY_ALIAS = K.SECURITY_ALIAS AND H.SRC_INTFC_INST = K.SRC_INTFC_INST)' ;
v_commit_after := 0;
INSERT_DATA_TO_TABLE(v_target_table,v_sql_to_run,v_commit_after);
/*EQUITY_DETAIL_HIST*/
v_target_table := 'X_EQUITY_DETAIL_HIST_TBL';
v_sql_to_run:= ' SELECT /*+DRIVING_SITE(K)*/ K.* FROM [email protected] K '||
' INNER JOIN SPOKE_TO_HUB_SEC_MTCH_TBL I'||
' ON K.SECURITY_ALIAS = I.SPOKE_SEC'||
' AND K.SRC_INTFC_INST = 140 '||
' and K.EFFECTIVE_DATE =(SELECT /*+DRIVING_SITE(H)*/ MAX (H.EFFECTIVE_DATE) FROM [email protected] H WHERE'||
' H.SECURITY_ALIAS = K.SECURITY_ALIAS AND H.SRC_INTFC_INST = K.SRC_INTFC_INST)' ;
v_commit_after := 0;
INSERT_DATA_TO_TABLE(v_target_table,v_sql_to_run,v_commit_after);
/*FIXED_INCOME_HIST*/
v_target_table := 'X_FIXED_INCOME_HIST_TBL';
v_sql_to_run:= ' SELECT /*+DRIVING_SITE(K)*/ K.* FROM [email protected] K '||
' INNER JOIN SPOKE_TO_HUB_SEC_MTCH_TBL I'||
' ON K.SECURITY_ALIAS = I.SPOKE_SEC'||
' AND K.SRC_INTFC_INST = 140 '||
' and K.EFFECTIVE_DATE =(SELECT /*+DRIVING_SITE(H)*/ MAX (H.EFFECTIVE_DATE) FROM [email protected] H WHERE'||
' H.SECURITY_ALIAS = K.SECURITY_ALIAS AND H.SRC_INTFC_INST = K.SRC_INTFC_INST)' ;
v_commit_after := 0;
INSERT_DATA_TO_TABLE(v_target_table,v_sql_to_run,v_commit_after);
/*FIXED_INCOME_DETAIL_EXT_HIST*/
v_target_table := 'X_FIXED_INCOME_DTL_EXT_TBL';
v_sql_to_run:= ' SELECT /*+DRIVING_SITE(K)*/ K.* FROM [email protected] K '||
' INNER JOIN SPOKE_TO_HUB_SEC_MTCH_TBL I'||
' ON K.SECURITY_ALIAS = I.SPOKE_SEC'||
' AND K.SRC_INTFC_INST = 140 '||
' and K.EFFECTIVE_DATE =(SELECT /*+DRIVING_SITE(H)*/ MAX (H.EFFECTIVE_DATE) FROM [email protected] H WHERE'||
' H.SECURITY_ALIAS = K.SECURITY_ALIAS AND H.SRC_INTFC_INST = K.SRC_INTFC_INST)' ;
v_commit_after := 0;
INSERT_DATA_TO_TABLE(v_target_table,v_sql_to_run,v_commit_after);
/*DERIVATIVES_HIST*/
v_target_table := 'X_DERIVATIVES_HIST_TBL';
v_sql_to_run:= ' SELECT /*+DRIVING_SITE(K)*/ K.* FROM [email protected] K '||
' INNER JOIN SPOKE_TO_HUB_SEC_MTCH_TBL I'||
' ON K.SECURITY_ALIAS = I.SPOKE_SEC'||
' AND K.SRC_INTFC_INST = 140 '||
' and K.EFFECTIVE_DATE =(SELECT /*+DRIVING_SITE(H)*/ MAX (H.EFFECTIVE_DATE) FROM [email protected] H WHERE'||
' H.SECURITY_ALIAS = K.SECURITY_ALIAS AND H.SRC_INTFC_INST = K.SRC_INTFC_INST)' ;
v_commit_after := 0;
INSERT_DATA_TO_TABLE(v_target_table,v_sql_to_run,v_commit_after);
END RETREIVE_RECORDS_FROM_SPOKE;
PROCEDURE COMPARE_RECORDS(p_err_msg OUT VARCHAR2)
AS
l_count NUMBER;
l_err_msg VARCHAR2(100);
TYPE T_SECURITIES is TABLE of HIST_DATA_COMPARE_TBL%rowtype;
ttype T_SECURITIES;
CURSOR C1
IS
SELECT TABLE_NAME, TEMP_TABLE, COLUMN_NAME from SEC_COMPARE_CONFIG
where column_name='EFFECTIVE_DATE';
CURSOR C2
IS
SELECT * FROM SEC_COMPARE_CONFIG where id <=82;
C_REC SEC_COMPARE_CONFIG%rowtype;
BEGIN
LC_SQL :='';
p_err_msg :='';
FOR C_REC in C1
loop
LC_SQL:= ' SELECT /*+DRIVING_SITE(B)*/ /*+PARALLEL(A,100)*/ B.SECURITY_ALIAS, to_char(C.SPOKE_PAID), A.SECURITY_ALIAS,to_char(C.HUB_PAID),'||''''||C_REC.TABLE_NAME||''''||','||q'!'EFFECTIVE_DATE'!'||','||
' NVL((cast(B.'||C_REC.COLUMN_NAME||' as VARCHAR2(100))),'||q'!'No Records Found'!'||'),'||
' NVL((cast(A.'||C_REC.COLUMN_NAME||' as VARCHAR2(100))),'||q'!'No Records Found'!'||')'||
' FROM '||C_REC.TEMP_TABLE||' A, SECURITYDBO.'||C_REC.TABLE_NAME ||'@PROD1.WORLD B,'||
' SPOKE_TO_HUB_SEC_MTCH_TBL C'||
' WHERE A.SRC_INTFC_INST=140'||
' AND B.SRC_INTFC_INST=140'||
' AND A.SECURITY_ALIAS=C.spoke_sec'||
' and b.security_alias=C.HUB_SEC'||
' AND a.effective_date <> (select max(h.effective_date) from SECURITYDBO.'||C_REC.TABLE_NAME||'@PROD1.WORLD H'||
' where h.security_alias=c.hub_sec and h.src_intfc_inst=140 )';
EXECUTE IMMEDIATE LC_SQL BULK COLLECT into ttype;
FORALL x in ttype.First..ttype.Last
insert into HIST_DATA_COMPARE_TBL values ttype(x);
commit;
end loop;
For C_REC in C2
loop
LC_SQL:= ' SELECT /*+DRIVING_SITE(B)*/ /*+PARALLEL(A,100)*/ B.SECURITY_ALIAS, to_char(C.SPOKE_PAID), A.SECURITY_ALIAS,to_char(C.HUB_PAID),'||''''||C_REC.TABLE_NAME||''''||','||''''||C_REC.COLUMN_NAME||''''||','||
' NVL((cast(B.'||C_REC.COLUMN_NAME||' as VARCHAR2(100))),'||q'!'No Records Found'!'||'),'||
' NVL((cast(A.'||C_REC.COLUMN_NAME||' as VARCHAR2(100))),'||q'!'No Records Found'!'||')'||
' FROM '||C_REC.TEMP_TABLE||' A, SECURITYDBO.'||C_REC.TABLE_NAME ||'@PROD1.WORLD B,'||
' SPOKE_TO_HUB_SEC_MTCH_TBL C'||
' WHERE A.SRC_INTFC_INST=140'||
' AND B.SRC_INTFC_INST=140'||
' AND A.SECURITY_ALIAS=C.spoke_sec'||
' and b.security_alias=C.HUB_SEC'||
' and b.effective_date=a.effective_date'||
' AND NVL((cast(A.'||C_REC.column_name||' as VARCHAR2(100))),'||q'!'No Records Found'!'||') <>'||
' NVL((cast(B.'||C_REC.column_name||' as VARCHAR2(100))),'||q'!'No Records Found'!'||')';
EXECUTE IMMEDIATE LC_SQL BULK COLLECT into ttype;
FORALL x in ttype.First..ttype.Last
insert into HIST_DATA_COMPARE_TBL values ttype(x);
commit;
end loop;
BEGIN
select count(*) into l_count from HIST_DATA_COMPARE_TBL;
if(l_count=0) then
l_err_msg :='No records found';
end if;
END;
END COMPARE_RECORDS;
NAME: INSERT_DATA_TO_TABLE
DESCRIPTION: This procedure will insert the records into the target table based based on the data fetched using the sql to run variable.
It also records the commit_after variable which defines that after how many records the insert needs to be committed.
PROCEDURE INSERT_DATA_TO_TABLE ( v_target_table VARCHAR2,
v_sql_to_run VARCHAR2,
v_commit_after NUMBER) IS
v_limit_sql1 VARCHAR2(300) := ' ';
v_limit_sql2 VARCHAR2(900) := ' ';
v_plsql_to_run VARCHAR2(32767);
BEGIN
IF NVL(v_commit_after,0) <> 0 THEN
v_limit_sql1:= ' LIMIT ' || TO_CHAR(v_commit_after) ;
v_limit_sql2:= ' IF MOD(v_number_of_rows, ' || TO_CHAR(v_commit_after) || ' ) = 0 THEN ' ||
' COMMIT; ' ||
' END IF; ' ;
END IF;
v_plsql_to_run:= ' ' ||
'DECLARE ' ||
' v_number_of_rows number:=0; ' ||
' ' ||
' TYPE MyType IS REF CURSOR; ' ||
' CV MyType; ' ||
' TYPE RecTyp IS TABLE OF ' || v_target_table || '%ROWTYPE; ' ||
' rec RecTyp; ' ||
' ' ||
'BEGIN ' ||
' ' ||
'OPEN CV FOR ' ||
' ' || REPLACE( v_sql_to_run, ';', ' ' ) || ' ; ' ||
' LOOP ' ||
' FETCH CV BULK COLLECT INTO rec ' || v_limit_sql1 || '; ' ||
' FORALL i IN 1..rec.COUNT ' ||
' INSERT /*+ APPEND */ INTO ' || v_target_table || ' VALUES rec(i); ' ||
' v_number_of_rows := v_number_of_rows + SQL%ROWCOUNT; ' ||
' ' || v_limit_sql2 || ' ' ||
' EXIT WHEN CV%NOTFOUND; ' ||
' ' ||
' END LOOP; ' ||
' COMMIT; ' ||
' CLOSE CV; ' ||
'END; ';
EXECUTE IMMEDIATE v_plsql_to_run;
COMMIT;
END INSERT_DATA_TO_TABLE;
END SECURITY_COMPARE; -
Need of SQL query in selecting distinct values from two tables
hi,
I need a query for selecting distinct values from two tables with one condition.
for eg:
there are two tables a & b.
in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
can anybody please help me.
Thanks in advance,
RatheeshNot sure what you mean either, but perhaps this will start a dialog:
SELECT DISTINCT a.empno,
a.name,
a.sex,
b.salary,
b.doj
FROM a,
b
WHERE a.empno = b.empno;Greg -
Trigger how to get new and old value for nested table column?
Hi,
I have created a nested table based on the following details:
CREATE TYPE typ_item AS OBJECT --create object
(prodid NUMBER(5),
price NUMBER(7,2) )
CREATE TYPE typ_item_nst -- define nested table type
AS TABLE OF typ_item
CREATE TABLE pOrder ( -- create database table
ordid NUMBER(5),
supplier NUMBER(5),
requester NUMBER(4),
ordered DATE,
items typ_item_nst)
NESTED TABLE items STORE AS item_stor_tab
INSERT INTO pOrder
VALUES (800, 80, 8000, sysdate,
typ_item_nst (typ_item (88, 888)));
Now I would like to create a trigger on table pOrder for after insert or update or delete
and I would like to track the new and old value for the columns inside nested table.
Can anybody direct me how to do it?
I would like to know the sytax for it like:
declare
x number;
begin
x := :new.nestedtablecolumn;--how to get the new and old value from nested table columns
end;
Hope my question is clear.
Thanks,
LavanHi,
Try like this:
CREATE OR REPLACE TRIGGER PORDER_I
BEFORE INSERT
ON PORDER
REFERENCING OLD AS old NEW AS new
FOR EACH ROW
DECLARE
items_new typ_item_nst;
ordid_NEW NUMBER;
BEGIN
FOR i IN :new.items.FIRST .. :new.items.LAST LOOP -- For first to last element
DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').prodid: ' || :new.items(I).prodid );
DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').price: ' || :new.items(I).price );
END LOOP;
END;Regards,
Peter -
Hi
how to create a external content type for Read and Update data from two tables in sqlserver using sharepoint designer 2010
i created a bcs service using centraladministration site
i have two tables in sqlserver
1)Employee
-empno
-firstname
-lastname
2)EmpDepartment
-empno
-deptno
-location
i want to just create a list to display employee details from two tables
empid firstname deptno location
and same time update in two tables
adilWhen I try to create an external content type based on a view (AdventureWorks2012.vSalesPerson) - I can display the data in an external list. When I attempt to edit it, I get an error:
External List fails when attached to a SQL view
Sorry, something went wrong
Failed to update a list item for this external list based on the Entity (External Content Type) 'SalesForce' in EntityNamespace 'http://xxxxxxxx'. Details: The query against the database caused an error.
I can edit the view in SQL Manager, so it seems strange that it fails.
Any advice would be greatly GREATLY appreciated.
Thanks,
Randy -
How to read .html file and store values into oracle table from html file
Hi all ,
How to read .html file and store values into oracle table from html file using pl/sql
Please Help.....Hi,
Kindly find following sample html code ,i want to store every value in different column in database .
<html><body><p/>
<div style="position:absolute;top:47px;left:37px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:47px;left:680px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:94px;left:151px;font-family:'Times New Roman';font-size:1pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:1080px;left:115px;font-family:'Times New Roman';font-size:8pt;white-space:nowrap;">4497743
</div>
<div style="position:absolute;top:1079px;left:442px;font-family:'Times New Roman';font-size:9pt;white-space:nowrap;"> Miclyn Express Offshore Pre-Quotation Disclosure
</div>
<div style="position:absolute;top:1079px;left:680px;font-family:'Times New Roman';font-size:9pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:1079px;left:723px;font-family:'Times New Roman';font-size:9pt;white-space:nowrap;">page 5
</div>
<div style="position:absolute;top:1083px;left:151px;font-family:'Times New Roman';font-size:1pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:107px;left:151px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>Attachment 2 ¿ indicative statement of 20 largest shareholders </b>
</div>
<div style="position:absolute;top:139px;left:262px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>Name </b>
</div>
<div style="position:absolute;top:131px;left:415px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>Number of Shares </b>
</div>
<div style="position:absolute;top:147px;left:458px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>Held </b>
</div>
<div style="position:absolute;top:131px;left:560px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>Percentage of </b>
</div>
<div style="position:absolute;top:147px;left:567px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;"><b>shares held </b>
</div>
<div style="position:absolute;top:179px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Macquarie Capital Group Limited 92,378,000
</div>
<div style="position:absolute;top:179px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:179px;left:618px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">34.00%r
</div>
<div style="position:absolute;top:179px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:212px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">HSBC Custody Nominees (Australia)
</div>
<div style="position:absolute;top:227px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Limited
</div>
<div style="position:absolute;top:220px;left:464px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">36,458,220
</div>
<div style="position:absolute;top:220px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:220px;left:618px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">13.42%
</div>
<div style="position:absolute;top:220px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:260px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Ray Rider Limited 27,170,000
</div>
<div style="position:absolute;top:260px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:260px;left:618px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">10.00%
</div>
<div style="position:absolute;top:260px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:300px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:300px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">7.96%
</div>
<div style="position:absolute;top:300px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:333px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">National Australia Bank Custodian
</div>
<div style="position:absolute;top:348px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Services
</div>
<div style="position:absolute;top:341px;left:464px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">12,866,550
</div>
<div style="position:absolute;top:341px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:341px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">4.74%
</div>
<div style="position:absolute;top:341px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:381px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Citigroup Nominees Pty Ltd 6,942,541
</div>
<div style="position:absolute;top:381px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:381px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">2.56%r
</div>
<div style="position:absolute;top:381px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:421px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:421px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">2.14%r
</div>
<div style="position:absolute;top:421px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:462px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">UBS Securities Australia Ltd 4,806,760
</div>
<div style="position:absolute;top:462px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:462px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">1.77%
</div>
<div style="position:absolute;top:462px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:494px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Merrill Lynch Equities (Australia)
</div>
<div style="position:absolute;top:510px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Limited
</div>
<div style="position:absolute;top:502px;left:472px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">4,325,000
</div>
<div style="position:absolute;top:502px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:502px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">1.59%
</div>
<div style="position:absolute;top:502px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:550px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Equities Ltd
</div>
<div style="position:absolute;top:542px;left:472px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">4,150,000
</div>
<div style="position:absolute;top:542px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:542px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">1.53%
</div>
<div style="position:absolute;top:542px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:575px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Bond Street Custodians Limited - A/C
</div>
<div style="position:absolute;top:590px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Institutional
</div>
<div style="position:absolute;top:583px;left:472px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">2,750,000
</div>
<div style="position:absolute;top:583px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:583px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">1.01%
</div>
<div style="position:absolute;top:583px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:623px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Cogent Investment Operations Pty Ltd 2,599,321
</div>
<div style="position:absolute;top:623px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:623px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.96%
</div>
<div style="position:absolute;top:623px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:663px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Skeet Nominees Pty Ltd 2,276,736
</div>
<div style="position:absolute;top:663px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:663px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.84%
</div>
<div style="position:absolute;top:663px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:704px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Diederik de Boer 1,917,561
</div>
<div style="position:absolute;top:704px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:704px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.71%
</div>
<div style="position:absolute;top:704px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:744px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Ecapital Nominees Pty Limited 1,594,736
</div>
<div style="position:absolute;top:744px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:744px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.59%
</div>
<div style="position:absolute;top:744px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:777px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Neweconomy Com Au Nominees Pty 9
</div>
<div style="position:absolute;top:792px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Limited <900 Account>
</div>
<div style="position:absolute;top:784px;left:472px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">1,594,7360
</div>
<div style="position:absolute;top:784px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:784px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.59%
</div>
<div style="position:absolute;top:784px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:825px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Sonray Capital Markets Pty Ltd 1,236,842
</div>
<div style="position:absolute;top:825px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:825px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.46%
</div>
<div style="position:absolute;top:825px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:865px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Argo Investments Limited 1,050,000
</div>
<div style="position:absolute;top:865px;left:531px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:865px;left:625px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">0.39%
</div>
<div style="position:absolute;top:865px;left:663px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">
</div>
<div style="position:absolute;top:905px;left:161px;font-family:'Times New Roman';font-size:11pt;white-space:nowrap;">Idameno (No 79) Nominees Pty Limited 724,210</div>
<div style="position:absolute;top:1103px;">
</body></html>
Thanks.......................... -
I want to read and assign value of ADF Table rows with Java Script
Hi,
I want to read and assign value of ADF Table rows with Java Script, but I cant true index of current row , so I assign wrong value to anathor column of ADF Table.
My Code;
ADF Table items
<af:column sortProperty="Adet" sortable="false"
headerText="#{bindings.RezervasyonWithParams1voHarcamaOdeme1.labels.Adet}"
binding="#{backing_ucret.column2}" id="column2">
<af:inputText value="#{row.Adet}"
required="#{bindings.RezervasyonWithParams1voHarcamaOdeme1.attrDefs.Adet.mandatory}"
columns="10"
binding="#{backing_ucret.inputText2}"
id="inputText2" onchange="getTutar('#{bindings.voHarcamaOdeme1Iterator.rangeStart + bindings.voHarcamaOdeme1Iterator.currentRowIndexInRange + 1}','#{bindings.voHarcamaOdeme1Iterator.estimatedRowCount}','#{row.index}')">
<f:convertNumber groupingUsed="false"
pattern="#{bindings.RezervasyonWithParams1voHarcamaOdeme1.formats.Adet}"/>
</af:inputText>
</af:column>
MY JAVA SCRIPT CODE
<f:verbatim>
<script language="javascript" type="text/javascript">
function getTutar(rowkey,totalrow,currentRow){
alert('rowkey--totalRow--currentRow-->'+rowkey+'--'+totalrow+'--'+currentRow);
if (currentRow==0) {
rowkey=totalrow-1;
}else{
var rw=totalrow-currentRow-1;
rowkey=rw;
alert(document.getElementById('form1:table1:'+rowkey+':inputText8').value);
alert(document.getElementById('form1:table1:'+currentRow+':inputText8').value);
var birim_ucret=document.getElementById('form1:table1:'+rowkey+':inputText8').value;
var adet=document.getElementById('form1:table1:'+rowkey+':inputText2').value;
document.getElementById('form1:table1:'+rowkey+':inputText3').value=birim_ucret*adet;
document.getElementById('form1:inputText6').value=0;
var t;
var toplam=0;
alert('before Sum');
for (var i=0;i!=totalrow-1;i++){
t = document.getElementById('form1:table1:'+i+':inputText3');
toplam+=t.value*1;
document.getElementById('form1:inputText6').value=toplam;
</script>
</f:verbatim>You can achieve the use case you describe with partial page rendering (PPR), a feature of the ADF Faces framework. Here are a few posts that achieve an interactive behavior using PPR. Off the top of my head I do not know of an exact example, but this should be a good starting point:
http://thepeninsulasedge.com/blog/2006/09/12/adf-faces-aftableselectmany/
http://thepeninsulasedge.com/blog/2006/08/31/adf-faces-working-with-aftableselectone-and-the-dialog-framework/
--RiC -
How to compare two internal table and store value in third table
Dear All,
There is two tabel say I_T1 & T2, in I_T1 there are 4 rows , in T2 there are multiple rows against the same field. Say there is a filed X common in both table .
Value of I_T1-X are
10
20
50
90
and value ot T2-X are
10
15
20
30
40
50
.100
Now i want to fetch data form T2 against the common field of I_T1-X and store into other internal table.
Plz suggest me the proper way of doing this.
Rewards points assured for proper answer.
Regards,
Gulrez Alamhi this is like your requirement.
in this i am storing the values into the final table
REPORT ZZZZ000000.
tables:mara,marc,mard,makt.
data:begin of it_mara occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
meins like mara-meins,
end of it_mara.
data:begin of it_marc occurs 0,
matnr like marc-matnr,
pstat like marc-pstat,
werks like marc-werks,
end of it_marc.
data:begin of it_mard occurs 0,
werks like mard-werks,
lgort like mard-lgort,
labst like mard-labst,
end of it_mard.
data:begin of it_final occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
meins like mara-meins,
pstat like marc-pstat,
werks like marc-werks,
lgort like mard-lgort,
labst like mard-labst,
maktx like makt-maktx,
end of it_final.
select-options:s_matnr for mara-matnr.
select matnr
mtart
meins
from mara
into table it_mara
where matnr in s_matnr.
if not it_mara[] is initial.
select matnr
pstat
werks
from marc
into table it_marc
for all entries in it_mara
where matnr = it_mara-matnr.
if not it_marc[] is initial.
select werks
lgort
labst
from mard
into table it_mard
for all entries in it_marc
where werks = it_marc-werks.
endif.
endif.
loop at it_mara.
it_final-matnr = it_mara-matnr.
it_final-mtart = it_mara-mtart.
it_final-meins = it_mara-meins.
read table it_marc with key matnr = it_mara-matnr.
it_final-werks = it_marc-werks.
it_final-pstat = it_marc-pstat.
read table it_mard with key werks = it_marc-werks.
it_final-lgort = it_mard-lgort.
it_final-labst = it_mard-labst.
if sy-subrc = 0.
select maktx from makt into it_final-maktx where matnr = it_final-matnr.
endselect.
endif.
append it_final.
endloop.
loop at it_final.
write:/ it_final-matnr under 'material',
it_final-mtart under 'material type',
it_final-meins under 'unit of measure',
it_final-werks under 'plant' ,
it_final-pstat under 'status',
it_final-lgort under 'storage loc',
it_final-labst under 'stock',
it_final-maktx.
endloop.
reward points if useful,
venkat. -
How to compare the names and types columns of two tables?
Assume I have two tables aaa and bbb
How do I compare the columnnames and types of the two columns?
It should not matter if one of them has e.g. an additional index.
Furthermore it does not matter if the rows/row values differ.
PeterSQL> desc emp
Nome Nullo? Tipo
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SQL> desc emp2
Nome Nullo? Tipo
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
MGR VARCHAR2(10)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
NEWCOL NUMBER
SQL> with t1 as
2 (select column_name, data_type from user_tab_columns where table_name='EMP'),
3 t2 as
4 (select column_name, data_type from user_tab_columns where table_name='EMP2')
5 Select a.column_name, a.data_type, b.column_name, b.data_type
6 from t1 a full outer join t2 b on a.column_name=b.column_name;
COLUMN_NAME DATA_TYPE COLUMN_NAME DATA_TYPE
EMPNO NUMBER EMPNO NUMBER
ENAME VARCHAR2 ENAME VARCHAR2
NEWCOL NUMBER
MGR NUMBER MGR VARCHAR2
HIREDATE DATE HIREDATE DATE
SAL NUMBER SAL NUMBER
COMM NUMBER COMM NUMBER
DEPTNO NUMBER DEPTNO NUMBER
JOB VARCHAR2
Selezionate 9 righe.Max
http://oracleitalia.wordpress.com
Edited by: Massimo Ruocchio on Feb 21, 2010 1:27 AM
Changed query. -
Filemaker-how to match and flag records in two tables
Hello,
Tiger.8
Filemaker Pro 8.5 Advanced
I have two related tables in an FMP file.
Table A has ~300 records, B ~2,000.
Each record in A is unique for sure; I believe each one in B is unique.
The goal is to determine whether any of the records in B match one in A based upon student ID.
These IDs are like social security numbers; i.e., they are preassigned, unique 9-character values rather than ones that I'm assigning within FMP.
Like SSNs, these IDs are unique. So within Table A, each ID is unique. Likewise, within B the IDs are unique.
However, some IDs in A might also be in B. I need to find out programmatically which ones, if any, are in both tables.
If a match exists, I need to flag a field in each table.
I found and modified an AppleScript that someone else wrote.
The original is as follows.
tell application "FileMaker Pro"
activate
show every record of database "Original Database"
show every record of database "Old Database"
set field "Match" of document "Original Database" to ""
set orgList to field "Full Name" of document "Original Database"
set oldList to field "Full Name" of document "Old Database"
set matchList to field "Match" of document "Original Database"
repeat with i from 1 to (count of orgList)
if oldList contains item i of orgList then
set item i of matchList to "Match"
end if
end repeat
set field "Match" of document "Original Database" to matchList
show (every record of database "Original Database" whose cell "Match" = "Match")
sort layout 2 of document "Original Database" by field "Last Name"
show layout 2 of document "Old Database"
end tell
My revision is as follows.
tell application "FileMaker Pro Advanced"
activate
show every record of table "A" of document "test"
show every record of table "B" of document "test"
set field "flag" of table "A" of document "test" to ""
set field "flag" of table "B" of document "test" to ""
set AList to field "ID" of table "A" of document "test"
set BList to field "ID" of table "B" of document "test"
set flagList to field "flag" of table "A" of document "test"
repeat with i from 1 to (count of AList)
if BList contains item i of AList then
set item i of flagList to "flag"
end if
end repeat
set field "flag" of table "A" of document "test" to flagList
set field "flag" of table "B" of document "test" to flagList
show (every record of database "test" whose cell "flag" = "flag")
sort layout 1 of document "test" by field "ID"
show layout 1 of document "test"
end tell
I sort of understand what each of the above commands does, but would appreciate answers to the following questions.
1. How come a test record that I created in A and B that has bogus ID 1234 does not get flagged by the above revised script, but other records with valid matching IDs in both A and B do get flagged?
2. How come all records in A that got flagged by the revised script do have counterparts in B, but only some of the ones in B that have a match in A got flagged?
3. How do the commands "set Alist" and "set Blist" function?
4. How do I fix the revised script so that it properly, correctly matches IDs between A and B, then properly, correctly flags the records in A and B that have matching IDs?
Many thanks in advance and happy weekend!
G4/1.25 MDD Mac OS X (10.4.8)>
as there any way find out using comparison same records in two tables..........
>
>
if i write a query then i can easily understand the same data is existed in two tables
>
So, what is your problem now?
You can join both the tables using a simple query and get the records.
select e1.empname, e2. empname from emp1 e1, emp2 e2 where
e1.empname = e2.empname and e1.empid = e2.empid -
Opening and Closing values on two separate rows for an indvidual A/c?
Hi / Salam To all SAP Members,
I am creating a COGS report in which i need to show opening and closing values for a stock account in two separate rows. The tool i am using is report painter.
What i need to know is how can the system identify between opening and closing values for that account? Which characteristic/s do i need to include in the rows? The table i am using is FAGLFLEXT.
Please provide help.
Regards,
Mohammed Ali Khan.Resolved Issue.
-
How to copy the value of two tables into a view.
Hi Experts ,
I have a requirement in which i have been provided with two tables(T1,T2) of same table structure ,i need to copy their entries into a table view with the same structure as the two tables(T1,T2) .
suppose T1 has entries name age T2 has entries
A 20 D 40
B 30 E 46
C 40
the view should have all the entries,duplicate values no issues ...
Could you please suggest how can i do that ?
Thanks and Regards
Debashisif table have same structure then you can use
select * from t1
union all
select * from t2 -
Min and Max values from entire table
Hi,
i have requirement in which i need to find the min and max values from the entire table.
See the sample data
create table test
Sal1 int,
Sal2 int,
Sal3 int
insert into test values (100,700,5700)
insert into test values (200,3300,5300)
insert into test values (4400,1200,3500)
insert into test values (5400,5600,3100)
i want the output as 100 and 5700.. how can i achieve this in a single query. Please through some light on this topic..!
Thanking you in advance
Regards,
Balaji Prasad B
Balaji - BI DeveloperBelow is an example with a subquery for each of the queries Mohammad posted in order to return both min and max in a single result set.
SELECT ( SELECT MAX(Maxx) AS Maxx
FROM test UNPIVOT
( Maxx FOR E IN ( Sal1, Sal2, Sal3 ) ) AS unpvt
) AS Maxx
, ( SELECT MIN(Minn) Minn
FROM test UNPIVOT
( Minn FOR E IN ( Sal1, Sal2, Sal3 ) ) AS unpvt
) AS Minxx;
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
How to parse XML Column and insert values into a table
Hello,
I am working on a simple project to demonstrate how to load and extract XML using SQL, I have already made a table that contains a column of XMLTYPE and loaded an XML file into it (code below)
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
I now however need to get the XML data back out of that and loaded into a new table. Troubleshooting guides I have read online seem to only be dealing with parsing an external XML document and loading it into a table, and not what I need to do which is parse a column of XML data and load that into a table. The project trivial with simple tables containing only 3 columns.
The table that needs to be loaded is as follows:
create table InventoryOut(PartNumber Number(10), QTY Number(10), WhLocation varchar2(500));
The XML document is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thank you for any help you can offer.First of all, thank you for your help!! Still stunned that you actually took the time to write out an eample using my tables/names/etc. Thank you!!
Attached is the code, there seems to be an issue with referencing the other table, Inventory.Inv, I checked and that table and the Inv column are showing up in the database so I am not sure why it is having issues locating them, take a look at the code I wrote as well as the output (*I included the real version number for you this time :)
EDIT: In your code right here:
select xt.*
3 from Inventory inve,
4 XMLTable('/dataroot/Inventory'
5 PASSING inve.Inv
I think is where I am messing it up, perhaps not understanding fully what is going on, as you write "Inventory inve" and "inve.Inv" ---- Is inve a keyword that I am just not familiar with? I think this is where the issues lies in my code.
END EDIT
EDIT2: Well that looks like it was it, changed that to how you have it and it now works!!! Could you please explain what that few lines is doing, and what the xt.* and inve are doing? Thanks again!!!
END EDIT2
drop table InventoryOut;
create table InventoryOut (PartNumber number(10), QTY number(10), WhLocation varchar2(500));
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt;
select * from InventoryOut;
select * from v$version;
table INVENTORYOUT dropped.
table INVENTORYOUT created.
Error starting at line 4 in command:
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt
Error at Command Line:8 Column:12
Error report:
SQL Error: ORA-00904: "INVENTORY"."INV": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
PARTNUMBER QTY WHLOCATION
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
If this helps here is the code and output for the creation of the Inventory table itself:
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
directory XMLSRC created.
table INVENTORY dropped.
table INVENTORY created.
1 rows inserted.
INV
<?xml version="1.0" encoding="WINDOWS-1252"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thanks again for your help so far! Hope we can get this working :)
Edited by: 926502 on Apr 11, 2012 2:47 PM
Edited by: 926502 on Apr 11, 2012 2:49 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Updated issue to solved - Edited by: 926502 on Apr 11, 2012 2:55 PM -
How to make validation in Bean and select value from another table
I want to know how to select data from table in backing bean according to primary key i have
the problem is that
i have a table Employee_Salary contains Employee ids and their salary
Empoloyee_Salary table
Employee_ID Number
Employee_salary Number
And Another table Called Employees
Employees table
Employee_ID Number
IsManager Varchar2 its value is [*Yes or NO*]
and other columns that i don't care about this table
i have on a jsff page an <af:table> this table is editable this is the Empoloyee_Salary table
*i want to check before save or after insert if this employee is Manager [from Employees tabke(yes or no)] the salary*
cannot be less that 100
i want to know how to make this how to select the value from employees table according to the id i have in the employee_salary table how to make this and make this validation
i have to select IsManager from Employees Table to see if this manager or no
i want to know how to make this in a bean
i use jdeveloper 11g
and my project is ADF Fusion project
and the page that have the Emplpyee_Salary table is JSFF
thanks in advanceYou might want to write this code in a validator on the entity object if it should apply from every screen.
If you want to access view objects from a backing bean the basics are here: http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcservices.htm#sthref918
Maybe you are looking for
-
ABAP routine/lookup in update rule
Hello Gurus, I am trying to do a lookup from 2 ODS's into one. I am trying to join sales and delivery data. My current idea is that I will use the 2LIS_11_V_SSL extractor that has SO, SOitm, DO, DOitm data and bring that into an ODS that has those fo
-
4-Pin to 6-Pin Firewire cable into new iMacs?
Hi, I have the new 27inch model iMac and as we know they have no firewire ports. I've got a Firewire to Thunderbolt adapter for my two external Firewire 800 hard drives. Question is I have my old Mini DV camcorder that I used to plug in with a 4-Pin
-
How do I convert my Raw Filws taken from my new Nikon d750 camera using Photoshop Elements 11??How do I convert my
-
My printer has a default margin of .25" at top and left, and .5" at the right and bottom page. I can't find anywhere to change this, even the print preview has it cut off, and I have no idea why! I'm working mainly with Photoshop, and my printer is
-
Transaction code to show previous tcodes used
Hi all, Gud morning... Is there any transaction code to view all the tcodes used by us?