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

Similar Messages

  • 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

  • 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

  • Using decode in where clause with user defined function

    Hi,
    I have a below query which is failing as the function in the decode taking all cust_account_id as input parameter instead of the one which satisfies the condition in the inner query.So please provide a solution how can i pass only the selected one.
    SELECT hca.cust_account_id
    FROM hz_cust_accounts hca
    WHERE hca.org_id=FND_PROFILE.value('ORG_ID')
    AND hca.cust_account_id = (SELECT DISTINCT hcasa.cust_account_id
    FROM hz_cust_acct_sites_all hcasa
    WHERE hcasa.cust_account_id =hca.cust_account_id
    AND hca.org_id = hcasa.org_id)
    AND DECODE (hca.status , 'A', xx_ar_cust_audit_pkg.get_ship_to_order_type(hca.cust_account_id)) IS NOT NULL
    Thanks,
    Abhilash

    I'm having to guess without access to your tables, but I think changing the IN to a join should produce the same results. The JOIN should be evaluated before applying the WHERE clause, so this may resolve your problem.
    SELECT hca.cust_account_id
    FROM   hz_cust_accounts hca
           INNER JOIN hz_cust_acct_sites_all hcasa
           ON    hcasa.cust_account_id = hca.cust_account_id
           AND   hca.org_id = hcasa.org_id
    WHERE  hca.org_id = FND_PROFILE.value('ORG_ID')
    AND    DECODE (hca.status , 'A', xx_ar_cust_audit_pkg.get_ship_to_order_type(hca.cust_account_id)) IS NOT NULLAlternately, you could next part of the query and break the DECODE into the parent so it is evaluated after the inner query. This is likely uglier from a performance standpoint, though:
    SELECT cust_account_id
    FROM
    SELECT hca.cust_account_id, hca.status
    FROM   hz_cust_accounts hca
    WHERE  hca.org_id=FND_PROFILE.value('ORG_ID')
    AND    hca.cust_account_id = (SELECT DISTINCT hcasa.cust_account_id
                                  FROM   hz_cust_acct_sites_all hcasa
                                  WHERE  hcasa.cust_account_id =hca.cust_account_id
                                  AND    hca.org_id = hcasa.org_id)
    WHERE DECODE (status , 'A', xx_ar_cust_audit_pkg.get_ship_to_order_type(cust_account_id)) IS NOT NULL;

  • How to migrate User Define Function to another mapping in other namespace

    Hi Everybody
    I have define many User Define Functions in mapping
    How can i use them in other mapping
    Thank you in advance

    Hi,
    I tried to explain the steps.
    1. Take the JAVA code of your User-Defined Functions
    2. Go to a JAVA editor (e.g NWDS, Eclipse, etc...)
    2.1. create a Java project
    2.2. create a Java class
    2.3. inside your Java class, put each JAVA code of your User-Defined Function inside a Method
    2.4. Export your Java class to a JAR file (e.g my_tools.jar)
    3. Go to IR
    3.1 create an Imported Archive (IA) and upload your JAR file.
    3.2 in this IA, you see your Java class which contains all your methods.
    4. inside your mapping,
    4.1 create a User-Defined Function <u>and import</u> your class
    4.2 use your method.
    So, you define in only one place your code (thanks to a IA) and you will be able to use it inside several mappings.
    I hope I don't forget steps...
    Advantage: if tomorrow, you want to create a new function, just add a new method to your Java class and re-import your JAR file
    Oh, I missed: your IA must be created inside a specific Software Component (SC__TOOLS) and this one must be linked with the others by a "Usage dependency", else your IA will be recognise only in one Software Component (and maybe only in one namespace)
    Mickael

  • 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.

  • 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 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 use PL/SQL table

    Hi all,
    can you guys suggest me how can I use pl/sql tables for the below query to incresing the performance.
    DECLARE
        TYPE cur_typ IS REF CURSOR;
        c           cur_typ;
        total_val varchar2(1000);
        sql_stmt varchar2(1000);
        freeform_name NUMBER;
        freeform_id NUMBER;
        imgname_rec EMC_FTW_PREVA.EMC_Image_C_Mungo%rowtype;
        imgval_rec  EMC_FTW_PREVA.EMC_Content_C_Mungo%rowtype;
        CURSOR imgname_cur IS
            select * from EMC_FTW_PREVA.EMC_Image_C_Mungo
            where cs_ownerid in (
                        select id from EMC_FTW_PREVA.EMC_Image_C
                        where updateddate > '01-JUN-13'
                        and path is not null
                        and createddate != updateddate)
            and cs_attrid = (select id from EMC_FTW_PREVA.EMC_ATTRIBUTE where name = 'Image_Upload');
    BEGIN
        OPEN imgname_cur;
        LOOP
          FETCH imgname_cur INTO imgname_rec;
          EXIT WHEN imgname_cur%NOTFOUND;
          total_val := 'EMC_Image_C_' || imgname_rec.cs_ownerid;
          sql_stmt := 'SELECT instr(textvalue,''' || total_val || '''), cs_ownerid FROM EMC_FTW_PREVA.EMC_Content_C_Mungo a Where cs_attrid = (select id from EMC_FTW_PREVA.EMC_ATTRIBUTE where name = ' || '''' || 'Body_freeform' || '''' || ')';
            OPEN c FOR sql_stmt;
            LOOP
              FETCH c INTO freeform_id,freeform_name;
              EXIT WHEN c%NOTFOUND;
                                      IF freeform_id > 0 THEN
                dbms_output.put_line (imgname_rec.cs_ownerid || ',' || total_val || ',' || freeform_id || ',' || freeform_name);
                                      END IF;
            END LOOP;
            CLOSE c;     
       END LOOP;
       CLOSE imgname_cur;
    END;
    Thanks in Advance.

    can you guys suggest me how can I use pl/sql tables for the below query to incresing the performance.
    There would be absolutely no point at all in improving the performance of code that has NO benefit.
    The only result of executing that code is to possibly produce some lines of output AFTER the entire procedure if finished:
    dbms_output.put_line (imgname_rec.cs_ownerid || ',' || total_val || ',' || freeform_id || ',' || freeform_name);
    So first you need to explain:
    1. what PROBLEM you are trying to solve?
    2. why you are trying to use PL/SQL code to solve it.
    3. why are you using 'slow by slow' (row by row) processing and then, for each row, opening a new cursor to query more data?
    You should be using a single query rather than two nested cursors. But that begs the question of what the code is even supposed to be doing since the only output is going to a memory buffer.

  • 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 use Pl/sql block to edit check user input

    Hi,
    Please advise on PL/SQL Block code that could be used to Check User input from within a Loop and proceed conditionally based upon User Supplied compliant Input. Thanks in advance.

    Hi,
    yakub21 wrote:
    You could use the ACCEPT to get user input and then assign the input to a variable that could then be verified.
    I believe that anything is possible because we don't yet have proof that it is not!
    I do have code that can accept user input. Is it PL/SQL code? Sybrand was clearly talking about PL/SQL:
    sybrand_b wrote:
    Pl/sql is for server side code, it is not a front end tool, and it is incapable of the functionality you describe.If you do have PL/SQL code that accepts user input, please post an example. A lot of people, including me, would be very interested.
    Pass the user-input value to a variable and then assign that value to another variable from within a Declare of a PL/SQL Block.
    The opportunity here is to figure a way to loop with user input until desired input is entered by the user before proceeding with the code. I'm using PL/SQL Block because I don't want the code to persist. I just want to run it as part of database configuration procedure. ThanksIt sounds like you're talking about SQL*Plus, which is a very poor tool for looping or branching.
    It's possible, but it's not pretty. The following thread shows one way of looping in SQL*Plus:
    Re: How to give the different values to runtime parameters in a loop?

  • How to Use Dynamic SQL

    Can anybody please send me a small program on How to Use Dynamic SQL.
    How to execute and run give details.
    Thanks
    null

    You can certainly use the INTO (and USING) clauses of EXECUTE IMMEDIATE to pass in and return data, i.e.
    EXECUTE IMMEDIATE sqlStmt
      USING variable1, variable2
       INTO output1, output2The more complex the statement, however, the more appropriate DBMS_SQL is. DBMS_SQL also has the potential to allow you to use bind variables rather than reparsing the statement many times.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to use the t-code vf31 tor taking print out of invoice

    Hi,
      How to use the t-code vf31 for taking print out,am getting an error like no message for initial processing exist,
    venu

    Hi,
    Please find the steps
    Output type                     RD00
    Transmission medium             1
    Sort order                      01
    Processing mode                 1
    Please give the oppropriate fields,
    if the still error persists  check the configuration in NACE transaction code.
    thanks
    Kuntla

  • Hi experts, how to use open sql to read data from one " maintenance view"?

    i want to use this part of data within report ,so how to use open sql statement to read data from one " maintenance view"?

    Hi
    You can't use OPEN SQl statements to fetch data from maintenance view
    You have to use only Database views
    see the different types of views and the difference
    The followings are different types of views:
    - Database View (SE11)
    Database views are implement an inner join, that is, only records of the primary table (selected via the join operation) for which the corresponding records of the secondary tables also exist are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a reduced selection set.
    In database views, the join conditions can be formulated using equality relationships between any base fields. In the other types of view, they must be taken from existing foreign keys. That is, tables can only be collected in a maintenance or help view if they are linked to one another via foreign keys.
    - Help View ( SE54)
    Help views are used to output additional information when the online help system is called.
    When the F4 button is pressed for a screen field, a check is first made on whether a matchcode is defined for this field. If this is not the case, the help view is displayed in which the check table of the field is the primary table. Thus, for each table no more than one help view can be created, that is, a table can only be primary table in at most one help view.
    - Projection View
    Projection views are used to suppress or mask certain fields in a table (projection), thus minimizing the number of interfaces. This means that only the data that is actually required is exchanged when the database is accessed.
    A projection view can draw upon only one table. Selection conditions cannot be specified for projection views.
    - Maintenance View ( SE54 )
    Maintenance views enable a business-oriented approach to looking at data, while at the same time, making it possible to maintain the data involved. Data from several tables can be summarized in a maintenance view and maintained collectively via this view. That is, the data is entered via the view and then distributed to the underlying tables by the system.
    Please have a look at below link. It will help you.
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ed06446011d189700000e8322d00/frameset.htm
    for more detailed info look on:
    http://www.sap-img.com/abap/what-is-the-different-types-and-usage-of-views.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/abap+dictionary&
    Reward points for useful Answers
    Regards
    Anji

  • How to use PDF417 Bar Code in Oracle Reports 6i

    How to Use PDF417 Bar Code in Oracle 6i. One of my clients has a requirement that Customer Name and Address to be converted into PDF417.
    Any help greatly appreciated.
    Thanks,
    PN

    You will need to add this font to the system and Reports configuration files.
    For adding font to the system, refer to your system specific guidelines for installing new fonts.
    After you have installed this font on the system, you should be able to see the font in Reports builder font picker dropdown box. or with unix 'xlsfonts' command
    For adding this font to the Reports application.
    1. Modify the printer definition file ( you can get this info from uiprint.txt file for the .ppd or .hpd file used )
    if the printer defination file is .ppd then look for "*Font Information" section and add the new font name there
    like *Font <new_font_name> Standard '(00.1001)" Standard ROM
    If hpd add the new font tfm file as
    FONT= new_font_name
    /tfm=new_font_tfm file.tfm
    2. Copy the AFM or TFM ( these are fonts metrics files, which font vendor will provide ) into the relevant directory so the the Reports application should pick them up.
    3. If necessary, make changes in the alias file (uifont.ali ) for mapping to this font. If the layout objects in your report are associated with the same font name as the new font then mapping is not required. But if the fonts for the layout objects are different then you need to map the original fonts to the new ones. Make sure that the mapping rules should be defined in the right section depending on the printer type being used.

Maybe you are looking for

  • Can no longer edit movies

    I no longer have the edit marks at the time line for videos. I checked and it still says Pro. I tried to remove the Quicktime preference files from my library folder and even un-registered the PRO serial number then re-registered it. I also downloade

  • System Update 5.0.2 fails to install on Windows 8.1 Preview

    I am trying to install System Update 5.0.2 on a W520 running a fresh install on Windows 8.1 Preview.  Solution Center is already installed.  No other software has been installed on this box, other than standard windows updates. When I try to install

  • HT5634 how can i remove windows 8 from my macbook pro

    how can i remove windows 8 from macbook pro

  • Quicktime 10 will not play video, only audio

    Hi - I cannot get my .mov files (with codec that is DV/DVCPRO - NTSC, Integer (Little Endian)) to play video in Quicktime 10... it will only play audio. That said, my .avi files from my digital camera play fine. I am running Snow Leopard 10.6.4. Any

  • Alv class

    CALL METHOD go_grid->set_table_for_first_display EXPORTING i_structure_name = 'SFLIGHT' CHANGING it_outtab = gi_sfligt iam new to alv class, plss help i want to know how will i get the class method go_grid? do i have to click on pattern? can anyone t