Friday, June 24, 2011

Unconnected Lookup Transformation -- Returning Multiple Values

> We can achieve Multiple values from Unconnected Lookup-Tr. We just need to override the default lookup sql query, there in one of the return port we can concatnate the values using ||.

> The concatnated multiple values will be returned from lookup to calling expression. In the expression we can extract / separate the concatnated string value (multiple values concatnated in lookup) and can pass to the target…

SELECT DEPT.DNAME||' '||DEPT.LOC as OUT_MUL_Values, DEPT.DNAME as DNAME, DEPT.LOC as LOC, DEPT.DEPTNO as DEPTNO FROM DEPT

> Before overrideing we should create one return port in the lookup-tr (here OUT_MUL_Values )

> Devide that OUT_MUL_Values in an expression

O_DNAME =     REG_EXTRACT(OUT_MUL_Values,'(\w+)\s+(\w+)',1)
O_LOC  =           REG_EXTRACT(OUT_MUL_Values,'(\w+)\s+(\w+)',2)

> Connect to target...

So here we are getting Multiple values using Unconnected Tr.


Thursday, June 23, 2011

2nd Workflow needs to run after 1st workflow finishes

Solution - 1

> Create a worklet_1 for running all of the session that you are running in wkf1 and create another worklet worklet_2 to run all of the session in wkf2.

> Now create a new Workflow and connect
start - > worklet_1 -> worklet_2.

> Edit the connection link between worklet_1 -> worklet_2 and set the condition as
worklet_1.Status=Succeeded.

---------------------------------------------------------------------------------------------

Solution - 2

> In this case you have to create a flat file at the end of wkf1 run.. by using
touchxyz.txt ......

> and in wkf2 use event wait task and use file watch event on that flatfile.

> In this solution if you run the wkf2 it will wait for the flat file to appear.. if not it
won't run



-- Ram

Friday, June 17, 2011

Having some cols in Aggregator and not given 'Sorted Input' as checked and we done GroupBy . What will happen? Whether it sorts the data first and do group by.. or ..directly do groupby.

      If your incoming data is in sorted manner and if we forgot to enable the option in Aggr-tr, then Integ serv still treates the rows as unsorted, and try to scan from the first Record onwards. It will sorts the data in the Group By port and next does Grouping..

     For example we have NAMES column which contains alphabet names, and we checked on group by on NAMES, then it will sorts the data first and does group by with corresponding columns.

SID      SNAME
1        Ram
1      Pothina
2      Anil
2      Kumar
  3      Doppal

In this above example .. if we do Group by on SNAME…It will sorts the names and then does Group By..

2              Anil
3              Doppal
2              kumar
1              Pothina
1              Ram



-- Ram

Tuesday, June 14, 2011

To load only requird Rows........

If you want to load only records 3rd, 5th, 10th..

SELECT * FROM (SELECT ROWNUM AS RNO,EMP.* FROM EMP)
WHERE RNO IN (3,5,10)
 







-- Ram

Monday, June 13, 2011

Sumup of Current Record and Previous Record

i have a source table which has only one column of some quantity.
and i want the sum of the last two rows  in the target table.

problem something like this...

Source  Target
Field       Field
1              1
2              3
3              5
4              7
5              9
6              11

Solutions





-- Ram


REGEX_MATCH() -- Example..

Source is a Flat File.  The Name Columns Contain Non-Alphabetic Character at any Position Like
  (0-9) (!@........so on) . We need to separate the data.

Names
Anudeep
Rajes4h
Pravee@n
Ra5mesh
Kuldeep
$reddy
Maya_

Target should be loaded as..

Target1                 Target2    
Anudeep                   Rajes4h
Kuldeep                     Pravee@n
                                    Ra5mesh
                                     $reddy  

Solution
Use the Informatica data comparision function REGEX_MATCH( ) to achieve this..
> Use Filter Condition as  REG_MATCH(Names,'^[a-zA-Z]+$')


-- Ram


Sunday, June 12, 2011

Half Records to one Target Half to another -- If Source is a Flat File ..

If your Source is FLAT FILE..


Half_Half_Loading_Flatfile.jpg
Design the two pipelines as shown above..
First Create a Mapping Variable $$Rec_Count


Second Pipeline

> Idea is to pick up Count of Rows using Aggrigator transformation using COUNT() function..... CNT = COUNT(*)
> Using Exp-Tr that value will be assigned to Mapping variable using SETVARIABL($$Rec_Count, CNT)
> Filter Tr is used with conditon set as FALSE.. becoz no records need to be loaded into target.
Here our idea is to find out RowCount and assigingin it to Mapping variable only..


First Pipeline


> In the Exp-Tr create a new port Rec_count (variable port) and increment it with 1 -- Rec_count + 1
This is becz inorder to generate seqnum with out using Seq-Gen-Tr ...
> Create o/p port  O_Rec_count = Rec_count
> Pass all ports to Router .. Create a group  and conditon as

Rec_Count <= ($$Rec_Count / 2)

Here $$Rec_Count is mapping variable.....
> Connect respective groups to targets.. mean default group to second target..

NOTE :  In this example Second pipeline should execute first so set ..
Target Load Order  : Second Pipeline first  -- First Pipeline next

Incremental Reading - Only one row at one session run..

How to load first record of first time run, Second record on 2nd time run... 3rd record on 3rd time run, to target table?

I understood your requirement as
When you load the session for the first time it has to load only 1st record. On the second run of the session it has to load 2nd record only, and so on... rit? If this is your requirement.. you can achieve this using Mapping variable concept.... Assuming  EMP schema as my source..

> Desing mapping as below..
incremental_load.jpg
> Crete and connect nexval port to Exp-Tr and Set Seq_Gen properties as: Check on Cycle, (Be clear with properties)
> Create Mapping Variable $$Var.
> In the Exp tr Create variable port and expression as   --  ' var_assign = $$Var + 1
> In the Filter Transformation write condition as   Condition :   seq_no = $$Var
> Connect to Target..
  


   For the first time run $$Var will hold intial value as 1 and first record will be loaded, and $$Var will be incremented by 1 in the Exp transformation . On the second run $$Var value will become 2 and only 2nd record will be loaded into the target.. and so on..


-- Ram

Half records to one target another Half to other..

--  In order to achieve this.. we need to design two pipelines..


-- In the first pipeline override the SQL Query as
  SELECT EMP.EMPNO, EMP.ENAME, EMP.JOB, EMP.MGR, EMP.HIREDATE, EMP.SAL, EMP.COMM, EMP.DEPTNO
FROM
 EMP WHERE ROWNUM < = (SELECT COUNT(*) /2 FROM EMP )


-- In the Second pipeline override the SQL Query as
  
SELECT EMP.EMPNO, EMP.ENAME, EMP.JOB, EMP.MGR, EMP.HIREDATE, EMP.SAL, EMP.COMM, EMP.DEPTNO
FROM
 EMP
MINUS
SELECT EMP.EMPNO, EMP.ENAME, EMP.JOB, EMP.MGR, EMP.HIREDATE, EMP.SAL, EMP.COMM, EMP.DEPTNO
FROM
 EMP WHERE ROWNUM <=(SELECT COUNT(*)/2 FROM EMP)


 -- Ram






I want to skip first 5 rows to load into target ?



> If your Source is a Flatfile and if you need to skip first 5 rows ...simply while Importing flatfile definition,
   set the properties as..Start import rows at option=6 .. generally 1 row goes as field names..so
   Start Import Rows at : 6

>  If  your source is a RDBMS, Override default SQL query as..

  SELECT * FROM EMP
  MINUS
  SELECT * FROM EMP WHERE rownum <=5

  so that records from 6 to n will be extracted by SQ..


> Other way..
   get the seq numbers using Seq-Gen-Tr.
   and in the Filter trasformation put condition as : seq_num > 5 .
   so only records from 5 - n records will be loaded into the target.

 

Thursday, June 9, 2011

While performing incremental reading using mapping variable using setvariable how can i increment date value ,can  u  explain in detail,which function i have to use ?

> Generally Incremental reading will be done using Dates comparisions.
src_date_field > $$Mapping_var_date  ... etc.. to load only recent records.. etc..


> Our sample senario is ... Wee need to extract the records .. ' whose update/insert date is to be 3 days before from Todays date '..
so i have set the mapping variable as...


       SETVARIABLE($$Date_To_Extract, ADD_TO_DATE(SYSDATE,'DD',-3))


- here $$Date_To_Extract is Mapping Variable...


-- Ram

Wednesday, June 8, 2011

Even Records - Odd Records Loading..

How to load odd values in one target  and even values another, if my source is rdbms and for flat files?


If your Source is RDBMS

Design two piplines with different targets as you wish.. order of ports should be same..

In SQ transformation Override the query as...
In first pipeline SQ
-- SELECT * FROM EMP WHERE (ROWID,0) IN (SELECT ROWID,MOD(ROWNUM,2) FROM EMP)
In second pipeline SQ
-- SELECT * FROM EMP WHERE (ROWID,1) IN (SELECT ROWID,MOD(ROWNUM,2) FROM EMP)

If your Source is a Flat file..

Generate Seq Nos using Seq-Tr by deriving new port in Exp-Tr.. 
Create Router group..create one group.
> Group1   --   mod(seq_no,2) != 0  -- connect to Even records Table
> Default Group  -- connect to Odd Records Table...


- Ram

Tuesday, June 7, 2011

Dynamically Changing Flatfile Name

How to change Target file name with session run time


If your Infa is 8.x later ver.. then you can go ahead as Swetha suggested..
> Add 'FileName' port to your target definition as a new port.
> and set  the Date Format setting for that Port in Properties..
> You can Derive one o/p port in Exp-tr with correct datatype and precision
> O_FileName :  'Tgt_File_'||TO_CHAR(SESSSTARTTIME,'DD/MM/YYYY HH24:MI')||'.csv'
Here Instead of using  'Sysdate' better to use SESSSTARTTIME .

Another way is....

> In the Workflow create a Workflow variable $$Se_End_Time
> In the Data Flow.. create Session task and Assignment Task .. and connect them
> In the assignment task / Expressions /
$$Se_End_Time   =  TO_CHAR($Session_Name.EndTime,'DD-MM-YYYY')

> Create a Parameter file
[Folder_Name.WF:wkf_Name.ST:session_Name]
$FileName=Tgt_File_
$DatePart=$$Se_End_Time


In the above file ..
> $$Se_End_Time is the Workflow variable....

In the Session Properties...
> Output FileName :  $FileName$DatePart .csv
> and set the parameter file path ...


-- Ram