Hi
In this entry i will implement more advance query over ODI 12c.Again I am gonna use ODIDEMO environment and implement following query.
select
sales.CUST_ID,CUST.CUST_NAME,
sales.PRODUCT,
sales.TOTAL_NUM_OF_ORDERS,
'%'||ROUND( (SUM_QUANTITY*100)/SUM_QUANTITY_ALL ) PER_QUANTITY
from
(
select
trg_customer.CUST_ID ,trg_customer.CUST_NAME
from
trg_customer where age>= 30 and age<=50
) cust ,
(
select
trg_sales.CUST_ID,
trg_product.PRODUCT ,
SUM(trg_sales.QTY) OVER (PARTITION BY trg_sales.CUST_ID) SUM_QUANTITY_ALL ,
SUM(trg_sales.QTY) OVER (PARTITION BY trg_sales.CUST_ID, trg_product.PRODUCT ) SUM_QUANTITY ,
COUNT(trg_sales.CUST_ID) OVER (PARTITION BY trg_sales.CUST_ID ) TOTAL_NUM_OF_ORDERS
from
trg_sales , trg_product
where
trg_sales.PRODUCT_ID = trg_product.PRODUCT_ID
) sales
where
sales.CUST_ID=cust.CUST_ID
At first we need prepare our datasource structure in mapping ( Sales and Customer )
Step1:
Prepare data source for sales subquery ( For this i will extract SALES and PRODUCT tables from MODEL--> SALES_ADMINISTRATION into SALES dataset and define the Join )
Step2:
Again in Sales part , we will gonna define our expressions
( TOTAL_NUM_OF_ORDERS ,SUM_QUANTITY , SUM_QUANTITY_ALL ).
To do that , first i will drag the columns which i need to use for calculation into expression object.
( CUST_ID , PRODUCT , QTY )
Step3:
Now i am gonna prepare CUSTOMER part of the query.For this i will extract TRG_CUSTOMER table from MODEL--> SALES_ADMINISTRATION into mapping and using filter object
( where age>= 30 and age<=50 )
Step4:
Okay , Currently we have two different datasource ( SALES , CUSTOMER) now according to query i will gonna merge these two set into one via join object.
Step5
As a final step , i will gonna map dataset into a target table.
Physical diagram as follows:
Note: For this example Source and Target tables are in same Oracle DB , so Default Oracle Knowledge Modules are used.
For Extraction: XKM Oracle Extract GLOBAL
For Integration: IKM Oracle Insert GLOBAL
19 Nisan 2014 Cumartesi
13 Nisan 2014 Pazar
ODI 12c Subquery Filter
Hi
In this entry i am gonna show how to implement an oracle pl/sql statement with subquery condition in ODI 12c.
Environment : ODI 12c & Oracle 11g
Sample Query which i will implement:
Target Table:
In this entry i am gonna show how to implement an oracle pl/sql statement with subquery condition in ODI 12c.
Environment : ODI 12c & Oracle 11g
Sample Query which i will implement:
select custid
from src_customer
where
custid in
(
select
CUST_ID
from src_orders
group by CUST_ID
having count(order_id) >3
)
Tables that we are using for this implementation:
Source table 1:
Source table 2:Target Table:
Mapping:
In above you can see the mapping we suppose use for this operation.Trick is hidden inside of the subquery filter object.
ODI already automatically set SRC_ORDERS table as a subquery table.Now only thing we have to do is to set Subquery filter filter properly .( Check the image above).For KMs standart knowledge modules works fine , you dont have to do any change.( For this example LKM Exract and IKM Oracle Global Knowledge modules were used. )
24 Mart 2014 Pazartesi
ORACLE - Add List partition with for loop
Following script let you create list partition between dates you specify.
Dates , tablename and tablespace are all depend on variables that you can change manually.
Dates , tablename and tablespace are all depend on variables that you can change manually.
DECLARE
p_BAS_TAR DATE ;
p_BIT_TAR DATE;
pTABLE_NAME VARCHAR2( 500 CHAR);
pTABLESPACE_NAME VARCHAR2( 500 CHAR);
DIFF NUMBER ;
INC_VAL NUMBER :=0;
V_DYNTASK LONG;
BEGIN
DIFF :=0;
p_BAS_TAR:= TO_DATE('20140316','YYYYMMDD') ; -- INCULING THIS DAY
p_BIT_TAR:= TO_DATE('20200101','YYYYMMDD') ; -- TILL THIS DAY NOT INCLUDED
pTABLE_NAME := 'TABLE_NAME; -- TABLE_NAME
pTABLESPACE_NAME:='TABLESPACE_ NAME'; -- TABLESPACE_NAME
SELECT trunc(TO_DATE(''||p_BIT_TAR||' ') ) - TO_date(TO_DATE(''||p_BAS_TAR| |'', 'dd/mm/yyyy') ) INTO DIFF FROM DUAL;
DBMS_OUTPUT.PUT_LINE(DIFF);
FOR Lcntr IN 1..DIFF
LOOP
V_DYNTASK:='ALTER TABLE '||pTABLE_NAME||' ADD PARTITION P_'||to_char(p_BAS_TAR, 'YYYYMMDD')||' VALUES (TO_DATE('''||p_BAS_TAR||''', ''dd.mm.yyyy'')) '||(case when pTABLESPACE_NAME is null then null else 'TABLESPACE '||pTABLESPACE_NAME end);
DBMS_OUTPUT.PUT_LINE(V_DYNTASK );
EXECUTE IMMEDIATE V_DYNTASK;
COMMIT;
p_BAS_TAR := p_BAS_TAR + 1;
END LOOP;
END;
5 Mart 2014 Çarşamba
Oracle - How to find invalid number row
Following sql can help to find rows which contains invalid number
select rowid as row_nums,
column_name
from
TABLE_NAME
where not
REGEXP_LIKE (column_name, '[[:digit:]]')
29 Aralık 2013 Pazar
ODI 10g Scheduler Agent on Unix
Hello
Well first of all you should go to your odiparam.sh file which inside of your folder.In this file you have to change the following path
ODI_SECU_DRIVER=driver name that suits with ur database that used as Work Rep.
ODI_SECU_URL=url of your work rep. database
ODI_SECU_USER=database user...
ODI_SECU_ENCODED_PASS=this is the encoded password of ur database user....
ODI_SECU_WORK_REP=name of your work rep.
ODI_USER=SUPERVISOR
ODI_ENCODED_PASS=LELKIELGLJMDLKMGHEHJDBGBGFDGGH
ODI_JAVA_HOME= u should write the exact path of any JDK that is already inside of your machine.... 5.1 or newer versions.
Here it is an example ::
ODI_SECU_DRIVER=oracle.jdbc.driver.OracleDriverODI_SECU_URL=jdbc:oracle:thin:@20.2.99.147:1521:DWXX
ODI_SECU_USER=mYusER
ODI_SECU_ENCODED_PASS=encoded_passODI_SECU_WORK_REP=myREP
ODI_USER=SUPERVISOR
ODI_ENCODED_PASS=LELKIELGLJMDLKMGHEHJDBGBGFDGGH
ODI_JAVA_HOME=/product/10g/db/jdk
your ODI_SECU_ENCODED_PASS should be look like ODI_ENCODED_PASS... which is the encoded password of ODI for SUPERVISOR
Well first of all you should go to your odiparam.sh file which inside of your folder.In this file you have to change the following path
ODI_SECU_DRIVER=driver name that suits with ur database that used as Work Rep.
ODI_SECU_URL=url of your work rep. database
ODI_SECU_USER=database user...
ODI_SECU_ENCODED_PASS=this is the encoded password of ur database user....
ODI_SECU_WORK_REP=name of your work rep.
ODI_USER=SUPERVISOR
ODI_ENCODED_PASS=LELKIELGLJMDLKMGHEHJDBGBGFDGGH
ODI_JAVA_HOME= u should write the exact path of any JDK that is already inside of your machine.... 5.1 or newer versions.
Here it is an example ::
ODI_SECU_DRIVER=oracle.jdbc.driver.OracleDriverODI_SECU_URL=jdbc:oracle:thin:@20.2.99.147:1521:DWXX
ODI_SECU_USER=mYusER
ODI_SECU_ENCODED_PASS=encoded_passODI_SECU_WORK_REP=myREP
ODI_USER=SUPERVISOR
ODI_ENCODED_PASS=LELKIELGLJMDLKMGHEHJDBGBGFDGGH
ODI_JAVA_HOME=/product/10g/db/jdk
your ODI_SECU_ENCODED_PASS should be look like ODI_ENCODED_PASS... which is the encoded password of ODI for SUPERVISOR
16 Aralık 2013 Pazartesi
Oracle - Clean Up duplicate keys
Case:
Assume that you have a table with duplicate ids , now you want to fix duplicate ids and want to make it all id values unique
Solution:
Step1: First collect a dataset for duplicate IDs
CREATE TABLE TMP AS
SELECT
ROWID DEST_ROWID ,
ID PREV_ID ,
( SELECT MAX( ID ) FROM TABLE_TEST S ) + ROWNUM NEW_ID
FROM TABLE_TEST
WHERE
ID IN
(
SELECT DISTINCT ID
FROM TABLE_TEST
GROUP BY ID
HAVING COUNT(1)>1
)
Step2: Now we have a table that contains DUPLICATE_IDs and ROWID value of our table ( which is useful for updates )
Step3: Assing PK to DEST_ROWID column on TMP table ( need for update )
Final Step:
UPDATE
(
SELECT A.ID TARGET_ID , B.NEW_ID UPD_ID
FROM
TABLE_TEST A , TMP B
WHERE
A.ROWID= B.DEST_ROWID
)
SET TARGET_ID = UPD_ID;
COMMIT;
Assume that you have a table with duplicate ids , now you want to fix duplicate ids and want to make it all id values unique
Solution:
Step1: First collect a dataset for duplicate IDs
CREATE TABLE TMP AS
SELECT
ROWID DEST_ROWID ,
ID PREV_ID ,
( SELECT MAX( ID ) FROM TABLE_TEST S ) + ROWNUM NEW_ID
FROM TABLE_TEST
WHERE
ID IN
(
SELECT DISTINCT ID
FROM TABLE_TEST
GROUP BY ID
HAVING COUNT(1)>1
)
Step2: Now we have a table that contains DUPLICATE_IDs and ROWID value of our table ( which is useful for updates )
Step3: Assing PK to DEST_ROWID column on TMP table ( need for update )
Final Step:
UPDATE
(
SELECT A.ID TARGET_ID , B.NEW_ID UPD_ID
FROM
TABLE_TEST A , TMP B
WHERE
A.ROWID= B.DEST_ROWID
)
SET TARGET_ID = UPD_ID;
COMMIT;
1 Kasım 2013 Cuma
INFORMATICA How to DENSE_RANK
EXAMPLE:
We want to make RANK object which is group by COL1,COL2 and ORDER BY COL4 ASC
STEP1:
CREATE TABLE RANKER_TMP -- SOURCE_TABLE
(
COL1 NUMBER,
COL2 VARCHAR2(100 CHAR) ,
COL3 VARCHAR2( 100 CHAR),
COL4 NUMBER
)
CREATE TABLE RANKER_TMP2 --- TARGET_TABLE
(
RANKER NUMBER,
COL1 NUMBER,
COL2 VARCHAR2(100 CHAR) ,
COL3 VARCHAR2( 100 CHAR),
COL4 NUMBER
)
STEP2:
Insert into RANKER_TMP
(COL1, COL2, COL3, COL4)
Values
(1, 'V', 'yes', 3);
Insert into RANKER_TMP
(COL1, COL2, COL3, COL4)
Values
(1, 'V', 'no', 3);
Insert into RANKER_TMP
(COL1, COL2, COL3, COL4)
Values
(1, 'V', 'YES', 2);
Insert into RANKER_TMP
(COL1, COL2, COL3, COL4)
Values
(2, 'b', 'yes', 1);
Insert into RANKER_TMP
(COL1, COL2, COL3, COL4)
Values
(2, 'b', 'no', 6);
Insert into RANKER_TMP
(COL1, COL2, COL3, COL4)
Values
(2, 'a', 'no', 2);
COMMIT;
STEP3:
In order to make DENSE_RANK we gonna use SORT and EXPRESSION objects together.Mapping should be look like this
*SORTER has to be SORTER BY COL1 ,COL2 , COL4 ASC ORDER
*In Informatica , EXPRESSION object calculates values from TOP to BOTTOM
( it first calculates INPUTs then VARIABLEs and last OUTPUTs. As a result , we can catch previous values by defining VARIABLE which map to COLUMN values )
EXPRESSION PORTS should be look like this :
* VAL_DIFF used for calculating RANK values. Formula should be look like this:
*Result :
Kaydol:
Kayıtlar (Atom)













.png)
.png)
.png)
