Procedures (or KM) Steps – Source and Target tab’s

Hi All,

There is some time that I don’t write a post, it’s because of the amount of work… too much clients, too much process… but all is perfect! I mean, work needs to exists because then it’s necessary people to do it! ;)

OK, today we are going to talk about those two tab’s at procedure step:

  • Source Tab
  • Target Tab

Obs.: When I say “Procedure Step” I mean “Procedure or KM Step” once this objects are almost the same but this is subject for another post.

Because of the interfaces, that has source and target tables, a obvious association is done and that is right. The difference is:

  • Interface:
    • Has Source and Target Table in generic way, KM’s are necessary to define how to push data from source to target normally in several steps
  • Source and Target Tab’s at Procedure Step:
    • It’s a single action (commands) between a defined source technology and a defined target technology

Before go to examples, a last information:

The most interesting and powerful characteristic of these tab’s is the ability of:

  • When a SQL query (select..) is executed in Source tab, the code wrote at Target tab will be executed once to each returned record from the SQL query

 

After theory and definitions, examples!

  • LKM SQL to SQL
    • This is the most classical example of functionality and interaction between the tab’s once, after create the C$, it transfers every single record from the query in the source to a “insert” command into target tab (Step 31 – Load Data) 
Code at sorce tab - LKM SQL to SQL

Code at sorce tab - LKM SQL to SQL

 Every single record returned from this query into Source Tab (as it is a LKM, the metadata commands will create the right command)
 
Will be inserted in C$ table by the following command into Target Tab: 
Insert command at Target Tab - LKM SQL to SQL

Insert command at Target Tab - LKM SQL to SQL

 
But this a example from a KM, could we try something in a Procedure?
 
Situation:
  • Send records fom a Postgre SQL table to an Oracle procedure
  • Source Query:
    • Select Name, Age from Client
  • Target Oracle Procedure:
    • pClient(Name as varchar, Age as date)

Before tell you how to implement, let me discuss about a very important issue: How are the returned values “delivered” to Target Tab???

Let’s remember few points:

  • ODI is a code generator
  • The generated code can be at any programming language or RDBMS command
  • ODI variables exists only in ODI, they aren’t able to exist inside, for instance, of a PL/SQL code in execution at Oracle database.

A new point that, maybe, you aren’t aware about is:

  • The responsible to execute the interaction between the Source and Table tab is the Agent

Note that we will send a query from Postrgre SQL to Oracle it means, two distinct RDBMS.

Agent is able to transform the data format

Agent is able to transform the data format

For Oracle people, this explain how ODI can integrate several Oracle databases with no DBLink.

As I mentioned above, ODI will generate the code and send it to the Oracle database, but how to indicate, in the generated code, where use a column from source?

It’s easy. The query I proposed is:

Select Name, Age from Client

The code for target tab will be:

Begin
   pClient(:Name, :Age);
End;

By using the column name prefixed with “:”, ODI understand that is to generate the Oracle code with the equivalent column from Postre query.

If a function was used in the souce like:

select EXTRACT(DAY FROM TIMESTAMP age) from Client

Just add an Alias and use it at target tab:

select EXTRACT(DAY FROM TIMESTAMP age) as Birthday from Client

 

Well, that is all friends!

The code at Target tab will be executed some many times as the amount of records returned from the Postgre query.

Just remember to setup the respective technology and Logical schema at each tab.

 Best Regards,

 

Cezar Santos

 



Posted: November 20th, 2009 | Author: | Filed under: Architecture, How to, Logic, ODI, Tips and Tricks | Tags: , , , , , , , , , , , , , , , , , , , , , , | Comments: 6 Comments »

6 Comments on “Procedures (or KM) Steps – Source and Target tab’s”

  1. 1 Josue Borges said at 6:06 am on October 22nd, 2010:

    Hey guys!

    In my case, the function snpRef.getColList returns quotes in the columns names.
    How can I remove them?

    Thanks!

  2. 2 Kshitiz Devendra said at 9:29 am on October 22nd, 2010:

    Hi Josue,
    Thanks for visiting us. Can you please try this way .
    < %=odiRef.getColList("", "[CX_COL_NAME]", ",\n\t", "","")%>

    In case you are still getting error , can you please let me know what is the code you are using , so we can guide you accordingly.

    Thanks
    Kshitiz Devendra

  3. 3 Josue Borges said at 11:38 am on October 22nd, 2010:

    Hi Kshitiz!

    When I used the function odiRef.getColList, the columns names in the query select generated were created with quotes, for example:
    select
    PRODUCTS.”cd_product”
    PRODUCTS.”desc_product”

    When that query runs, an error happens. In my case, Oracle doesn’t know columns with quotes. I think that’s a database configuration, I don’t know…

    So, I’d like to know if is possible to edit the LKM SQL to SQL to use some function (or something like this) to remove the quotes. Or if I can to solve the problem through another way…

    Thanks!

  4. 4 Kshitiz Devendra said at 2:23 pm on October 22nd, 2010:

    The reason is that ODI automatically applies the column name with double quotes if the column name is in lowercase .
    The solution is to use the capital name for the column name and try , ODI won’t add the double quote then.
    So cd_product should CD_PRODUCT ,desc_product should be DESC_PRODUCT

  5. 5 Kalyan said at 8:27 pm on June 6th, 2011:

    Hi All,

    We have migrated from sunopsis to ODI recently .The interface is quite simple generating files with double quotes to delimit the fields. the fields are separated by ;
    the result is different with ODI than with sunopsis. we only migrate and don’t change the interfaces.

    with sunopsis a field contains a ” character : sunopsis double it automatically
    now ODI does nothing on the quotes and we get unbalanced quotes.

    I have used the following Datastore- Files Delimiter options.
    Datastore -> Files Tab
    a) File Format – Delimited
    b) Heading (number of lines) – 0
    c) Record Separator – MSDOS
    d) Field Separator – Other (;) Hexadecimal (3B)
    e) Text Delimiter – ”
    f) Decimal Separator – ,

    Request for your valuable pointers on this.

    Thanks & Regards,
    Kalyan

  6. 6 Cezar Santos said at 11:57 am on June 7th, 2011:

    Hi Kalyan,

    Good to see you around…

    Please, send me an email in cezar.santos@odiexperts.com with a sample of the ODI 11g generated file…


Leave a Reply