Using PL/SQL code in ODI User Functions

Is it possible to write PL/SQL code (with multiple in params and one out param) in ODI User Function ?
Actually I need to use this user functions in my interface mapping.
I know it can be done using ODI Procedures but Procedures cannot be used within interfaces when mapping columns.

Hi Anurag Ambasta,
You can use the ODI user functions and choose the Linked technology as 'Oracle' where you can implement and use oracle syntax .
And the user functions can receive the multiple parameters and it returns the single value to the function cal, which use are expecting right?
Thanks,
Yellanki

Similar Messages

  • How to use pl/sql code as ODI user defined function

    Hi All,
    i have a pl/sql code and i want to create ODI user defined function using this code .
    please find the pl/sql code below:
    ============================
    declare
    v_no_of_duplicate_rec number := 0;
    begin
    select count(*)
    into v_no_of_duplicate_rec
    from ( select 1
    from temp_pre_selections
    group by svb_number, selection_id
    having count(*) > 1);
    if v_no_of_duplicate_rec = 0 then
    return 'N';
    else
    return 'Y';
    end if;
    end if;
    ==========================
    please help me how to achieve the same .
    Thanks
    Vinod

    2 ways:
    a. implement logic in odi function directly: getCount, Oracle implementation:
    select case count(1) when 0 then 'N' else 'Y' end
    from hr.employees
    when you use this function to refresh a variable, the refresh statement should only be getCount, you shoueld not write select getCount from dual, otherwise it will become
    select select .... from ... from dual
    b. if your logic is complex, I suggest to write function directly in your database, then call this function in your ODI function
    eg:
    CREATE OR REPLACE FUNCTION hr.test RETURN varchar2 IS
    tmpVar NUMBER;
    BEGIN
    select count(1) into tmpVar from hr.employees;
    if tmpVar=0 then
    return 'N';
    else
    return 'Y';
    end if;
    END test;
    then create a ODI function, Oracle implementation is
    hr.test
    in your variable refresh statement, you can write select getCount from dual
    if you use the odi function in other locations expect for refreshing variable, the idea is similar

  • How to retrieve the current User using PL_/SQL code?

    Hi,
    How can find the current logged user within a Dynamic Page using PL/SQL code?
    Thanks.

    Hi,
    There is a function wwctx_api.get_user which returns the logged in user. You can use this in your plsql code.
    Thanks,
    Sharmila

  • How can one  read a Excel File and Upload into Table using Pl/SQL Code.

    How can one read a Excel File and Upload into Table using Pl/SQL Code.
    1. Excel File is on My PC.
    2. And I want to write a Stored Procedure or Package to do that.
    3. DataBase is on Other Server. Client-Server Environment.
    4. I am Using Toad or PlSql developer tool.

    If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
    1. Get your DBA to create directory object in oracle using the following command:
    create directory TEST_DIR as ‘directory_path’;
    Note: This directory is on the server.
    2. Grant read,write on directory directory_object_name to username;
    You can find out the directory_object_name value from dba_directories view if you are using the system user account.
    3. Logon as the user as mentioned above.
    Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
    function getData(p_filename in varchar2,
    p_filepath in varchar2
    ) RETURN VARCHAR2 is
    input_file utl_file.file_type;
    --declare a buffer to read text data
    input_buffer varchar2(4000);
    begin
    --using the UTL_FILE in built package
    input_file := utl_file.fopen(p_filepath, p_filename, 'R');
    utl_file.get_line(input_file, input_buffer);
    --debug
    --dbms_output.put_line(input_buffer);
    utl_file.fclose(input_file);
    --return data
    return input_buffer;
    end;
    Hope this helps.

  • Can I create a file using pl/sql code in application server ?

    Hi
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?
    Please help me with an example...in this regard
    Regards
    Sa

    864334 wrote:
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?And how is this "file" to be delivered?
    Files can be created by PL/SQL code and stored in the Oracle database as CLOBs. This a fairly easy and robust process. It runs entirely in the database. It conforms to transaction processing. The "file" (as a CLOB) resides in the database and can thus be secured via database security, is part of database backups and so on.
    The basic issue is how to deliver the contents of the CLOB to the user. If via FTP, then the database can directly FTP the contents of the CLOB to the FTP server as a file. If via HTTP, the database can deliver the CLOB as a HTTP download directly to the web browser.
    If the client is Java or .Net, then the CLOB contents can be delivered via SQL or DBMS_LOB or a custom PL/SQL interface.
    In such cases, there is no need to step outside the secure and flexible database environment and create a physical o/s file in the wild (outside the controls of database security, data integrity and transaction processing). This is thus recommended and is the preference.

  • How to call PL/SQL code from ODI

    Hello friends,
    Can you please let me the steps for calling a pl/sql code in ODI?
    Regards
    Ulhas

    This should give you an idea - http://odiexperts.com/?p=666

  • How to create dynamic HTML page using PL/SQL code in APEX.

    hello,
    I am woking on one APEX application in which i want to create one dynamic HTML page on button press using PL/SQL code.
    Thanks

    It is possible to create HTML page with dynamic content. One way would be creating hidden field (e.g. P1_HTML on page 1) with dynamic HTML and on button click you redirect to page 2 and pass P1_HTML item value to item P2_HTML on page 2. On page you must have PL/SQL region. You can then render your dynamic HTML with code:
    htp.p(:P2_HTML);
    Don use APEX URL for passing HTML value. Problem and solution is described here: http://blog.trent-schafer.com/2011/04/03/dont-pass-string-parameters-in-the-url-in-apex-its-a-bad-idea/
    Edited by: MiroMas on 3.2.2012 3:20

  • How to get the home page for a user using  Pl/sql code ?

    Hi,
    I have a pl/sql procedure which runs after a form submission on a dynamic page. At end of completion of the procedure I want to send user to his/her home page. I am trying to write at the end of procedure to redirect the user to the home page. How do I do that ? What is way to redirect to a page using pl/sql and how do I know the user home page url ?
    thanks,
    Mainak

    Hi,
    Try <portalschema>.wwv_redirect.url('<portalschema>.home');
    Please replace portalschema with the name of your portal schema.
    Thanks,
    Sharmila

  • Using the Dollar($) Sign in a User Function Implementation

    Hi All,
    Just a quick question: how could you use a dollar($) sign in the implementation (Oracle) of a user function? I'm asking because the table name that I'm using in the implementation happens to contain the dollar sign (I$_FACT_SALES) and from the results I'm getting now, ODI reads the $ as reference to a variable, therefore removing the $-sign from my table name upon execution (I_FACT_SALES). Is there something like a backslash or some other character that could be inserted before the $ so it would register as part of the table name?
    Any response would be greatly appreciated.
    Thanks very much,
    Marco

    You may have 3 options:
    1.) Try using the tablename in quotes "MY$TABLE" or may be MY$$TABLE using double $ symbol
    or
    2.) I found this code snippet : odiRef.getInfo( \\u0022DEST_WORK_SCHEMA\\u0022 )+\\u0022.\\u0022,\\u0022\\u0022)?. So on these lines you can use \\u0022 as a symbol for "
    You can see similar problem/solution/explanation in
    Re: Regular Expression wierdness - problem with $ character
    or
    3.) Change the Work Tables Prefix in Topology Manager > Physical Schema > Your_Schema
    from E$_ , C$_ , I$_ to something like ERR_ , SRC_ , INT_
    Edited by: Ace2 on Dec 2, 2009 9:57 AM

  • Incorrect Results When Using an In-Line View and User Function in 10g

    My developers are complaining of incorrect Select statement results when using an in-line view along with a user defined function. Below is the statement:
    select test_f(wo1)
    from
    (SELECT a.WORK_ORDER_NBR, b.work_order_nbr wo1/*, facility_f(A.FACILITY),
    A.PLANNER, A.WO_STATUS, mil_date(A.WO_STATUS_DATE)*, A.WORK_ORDER_TYPE,
    A.WO_DESCRIPTION
    FROM TIDWOWRK A, TIDWOTSK B
    WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR))
    where wo1 is null;
    Test_f() is a user defined function and the above query returns thousands of rows. It should return 308 rows. It is apparent that the target database is not evaluating the "where wo1 is null;" clause.
    select to_char(wo1)
    from
    (SELECT a.WORK_ORDER_NBR, b.work_order_nbr wo1/*, facility_f(A.FACILITY),
    A.PLANNER, A.WO_STATUS, mil_date(A.WO_STATUS_DATE)*, A.WORK_ORDER_TYPE,
    A.WO_DESCRIPTION
    FROM TIDWOWRK A, TIDWOTSK B
    WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR))
    where wo1 is null;
    In the above query return 308 rows. The user function was replaced by an Oracle function. The Where clause is now evaluated correctly.
    The query is executed from an Oracle 10g R2 database and retrieves data from a 9.2.0.6 database.
    I've seen a little information on Metalink. It appears that there was some trouble in 9i, but were fixed in a 9.2.0.6 patch. I don't see any information about a 10.2.0.2 database.
    Anyone have any experiences or a successful solution. I suspect that I will need to report this to Oracle and wait for a patch.
    Thanks,
    John

    I can only think of two reasons for this behaviour:
    1) You are executing these two queries from two different users and there is some policy on the table.
    2) The function doesn't do an upper, but returns null a lot of times, even when the input is a not null value, like this:
    SQL> create table tidwowrk
      2  as
      3  select 1 id, 'A' work_order_nbr, 'DST' facility from dual union all
      4  select 2, null, 'TRN' from dual union all
      5  select 3, 'C', 'DST' from dual
      6  /
    Tabel is aangemaakt.
    SQL> create table tidwotsk
      2  as
      3  select 'A' work_order_nbr from dual union all
      4  select 'B' from dual
      5  /
    Tabel is aangemaakt.
    SQL> create or replace function test_f (a in varchar2) return varchar2
      2  is
      3  begin
      4    return case a when 'A' then null else a end;
      5  end;
      6  /
    Functie is aangemaakt.
    SQL> select count(*)
      2    from ( SELECT a.WORK_ORDER_NBR
      3                , test_f(b.work_order_nbr) wo1
      4             FROM TIDWOWRK A
      5                , TIDWOTSK B
      6            WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR
      7              and a.facility in ('DST', 'TRN', 'SUB')
      8         )
      9   where wo1 is null
    10  /
                                  COUNT(*)
                                         3
    1 rij is geselecteerd.
    SQL> select count(*)
      2    from ( SELECT a.WORK_ORDER_NBR
      3                , to_char(b.work_order_nbr) wo1
      4             FROM TIDWOWRK A, TIDWOTSK B
      5            WHERE B.WORK_ORDER_NBR(+) = A.WORK_ORDER_NBR
      6              and a.facility in ('DST', 'TRN', 'SUB')
      7         )
      8   where wo1 is null
      9  /
                                  COUNT(*)
                                         2
    1 rij is geselecteerd.Regards,
    Rob.

  • Dynamic PL/SQL code into ODI Procedure

    Hi guys:
    I have a PL/SQL code to execute into a ODI proc that changes because of a loop.
    I have to update N tables that have the same prefix and its sufix is the dynamic part of my PL/SQL. Also I have to set the DT_ETL (I already have a variable in my package with the sysdate) and the limit of a rownum.
    These are my variables:
    vGET_CD_BASE*
    vQTD_REG_UPDATE*
    vETL_DATE*
    The PL/SQL is described below (with the dynamic parts of it as ODI variables #vXXXXX):
    DECLARE
    CURSOR v_Cur IS
    SELECT ROWID KEY_ROW FROM GG_DATA.WRK_SN_DET_ITEM_EXTR_PARC_*#vGET_CD_BASE* WHERE DT_ETL = TO_DATE('01/01/1900','DD/MM/YYYY') and rownum < *#vQTD_REG_UPDATE*;
    TYPE t_Tabela IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
    r_Reg t_Tabela;
    BEGIN
    OPEN v_Cur;
    LOOP
    FETCH v_Cur BULK COLLECT INTO r_Reg LIMIT 100000;
    FORALL i IN 1..r_Reg.COUNT
    UPDATE GG_DATA.WRK_SN_DET_ITEM_EXTR_PARC_*#vGET_CD_BASE*
    SET DT_ETL = TO_DATE('*#vETL_DATE*','DD/MM/YYYY HH24:MI:SS')
    WHERE ROWID = r_Reg(i);
    EXIT WHEN v_Cur%NOTFOUND;
    COMMIT;
    END LOOP;
    CLOSE v_Cur;
    COMMIT;
    END;
    What do I have to change to make this PL/SQL works in ODI Procedure?
    Regards.
    Luiz Araujo

    Luiz,
    One way you could do is by using the "Command on Source" and "Command on Target" feature of an ODI procedure:
    In Command on Source, you can write query like:
    >
    select vGET_CD_BASE, vQTD_REG_UPDATE, vETL_DATE from some_configuration_table_containing_n_rows
    >
    In Command on Target, you can write:
    >
    DECLARE
    CURSOR v_Cur IS
    SELECT ROWID KEY_ROW FROM GG_DATA.WRK_SN_DET_ITEM_EXTR_PARC_#vGET_CD_BASE WHERE DT_ETL = TO_DATE('01/01/1900','DD/MM/YYYY') and rownum < #vQTD_REG_UPDATE;
    TYPE t_Tabela IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
    r_Reg t_Tabela;
    BEGIN
    OPEN v_Cur;
    LOOP
    FETCH v_Cur BULK COLLECT INTO r_Reg LIMIT 100000;
    FORALL i IN 1..r_Reg.COUNT
    UPDATE GG_DATA.WRK_SN_DET_ITEM_EXTR_PARC_#vGET_CD_BASE
    SET DT_ETL = TO_DATE('*#vETL_DATE*','DD/MM/YYYY HH24:MI:SS')
    WHERE ROWID = r_Reg(i);
    EXIT WHEN v_Cur%NOTFOUND;
    COMMIT;
    END LOOP;
    CLOSE v_Cur;
    COMMIT;
    END;
    >
    So, for "n" records that are returned by the source query, your PL/SQL package will run "n" times, each time substituting the values of vGET_CD_BASE, vQTD_REG_UPDATE, vETL_DATE respectively.

  • Dynamically create javascripts using pl/sql code from page header

    I understand by placing a javascript code in the page header is one of the way adding javascript functionality to your pages.
    But lets say I need (dynamically) bring my javascripts into the page header using my pl/sql package/functions like core_func_jscript_pkg.get_jscript('jf_isnumber');
    1- How can I call my pl/sql package/functions from page header area of Apex?
    If I need to use 20 javascripts functions into a page which I have them stored in database (using them on my other pages) and I don't want to copy or re-write them in Apex, instead I like to have 20 line of calls to my pl/sql package like:
    core_func_jscript_pkg.get_jscript('myFirstJavascript');
    core_func_jscript_pkg.get_jscript('mySecondJavascript');
    core_func_jscript_pkg.get_jscript('myThirdJavascript');
    core_func_jscript_pkg.get_jscript('myFourthJavascript');
    ... and so on.
    2- In past we wrote our web apps using pl/sql example:
    htp.p('<html>');
    htp.p('<head>');
    core_func_jscript_pkg.get_jscript('jf_get_today_date');
    core_func_jscript_pkg.get_jscript('someothe_scripts');
    htp.p('</head>');
    htp.p('</html>');
    I like to do the same thing in Apex, Can I accomplish this in Apex?
    Thanks again
    -iahmadi

    There was a <head> content & dynamic metadata with APEX? that should provide some pointers.

  • Generate SQL code from a user

    Hi,
    I would like to replicate a user from one database to another.
    Is it possible to generate the SQL code that defines this user, in the purpose of apply this script on another database ?
    Thanks.

    Hi
    You can use DBMS_METADATA package:
    SELECT DBMS_METADATA.GET_DDL('USER', 'GOKHAN') FROM DUAL;
    SELECT DBMS_METADATA.GET_GRANTED_DDL('ROLE_GRANT', 'GOKHAN') FROM DUAL;
    SELECT DBMS_METADATA.GET_GRANTED_DDL('SYSTEM_GRANT', 'GOKHAN') FROM DUAL;
    SELECT DBMS_METADATA.GET_GRANTED_DDL('OBJECT_GRANT', 'GOKHAN') FROM DUAL;I put 'GOKHAN' as sample user name.
    Ref: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_metada.htm
    Best Regards,
    Gokhan Atil
    If this question is answered, please mark appropriate posts as correct/helpful and the thread as closed. Thanks

  • How to Export data from a Table to Excel using PL/SQL Code

    Hi,
    I need to export data from a table to the excel sheet using PL/SQL script.
    could you pls provide with custom codes or sample procedures.
    Bobby

    http://asktom.oracle.com/pls/ask/f?p=4950:8:7947129213057862756::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:728625409049

  • Portal: Use of SQL code

    Hi
    I have tried to put some SQL code in some Forms, in the part where it is suppoused to be put (where it says after display page, after display form, etc) but it doesn4t work. I don4t know how the syntaxis must be so I wonder if someone could help me. For example, I would like to execute a SELECT before the display of a page, puting the corresponding code in the part of the Form mentionated before.
    Thanks.

    Use something like :-
    declare
    cursor c1 is select ename from scott.emp;
    begin
    for i in c1
    loop
    htp.p(c1.ename);
    end loop;
    end;

Maybe you are looking for

  • How do I transfer the music from my phone to iTunes?

    Need help with transferring my music and pictures into my iTunes that doesn't have them there already.

  • SAP Backups ; R/3 & file system

    Hello, What is the different between SAP R/3 backup and SAP File System backup? what are the files that backing up in each cases To which back up does the oracle DB fit in. (Data Files,Control files, Redo Logs, SPFILE) To which back up does the O/S f

  • Unable to receive all fields at receiver

    Hi, I have simple scenario from file to file using file content conversion at both sides. <b>Strucure of my file is</b> MT_emp_profile    Details |_Records           |_emp_no           |_ emp_name           |_ emp_dno. My file is getting created at r

  • Question: Migration from Tibco BW to SAP XI

    I have been actively involved in TIBCO BW projects as project co-ordinator for the past year. Now i am thinking of shifting into SAP XI. I am assuming that SAP XI has the same underlying concept as TIBCO BW. Is my assumption correct? If yes then how

  • Workflow - Very urgent

    Hi I´m really stuck with an problem that I have regarding the workflows in EP5 SP6. In DB where can I find the definitions of the workflows? I've only found the workflows for documents that were already realized or are in process(table wcm_aib_assign