How to run dynamic SQL from an ODI procedure step

I am on ODI 11.1.1.6.4. From within an ODI IKM step I have no problem running a procedure step like the following which calls a pl/sql procedure to get SQL text then later runs that code. Is there anyway to do the same from within an ODI procedure? I've tried a couple of variations and can not seem to get the parsing levels to resolve within a procedure like they resolve from within a KM step.
<@
/* Setup Java variables */
String out_SQL = "";
try
java.sql.Connection sourceConnection = odiRef.getJDBCConnection("SRC");
String sqltxt = "{call set_sql(?)}";
java.sql.CallableStatement pstmt = sourceConnection.prepareCall(sqltxt);
     try
     pstmt.registerOutParameter( 1, java.sql.Types.VARCHAR);
     pstmt.execute();
out_SQL = pstmt.getString(1);
     catch(java.sql.SQLException ex)
          errMessage = ex.getMessage();
          errMessage = errMessage.replace("'","");
     finally
          pstmt.close();
catch(java.lang.Exception e)
     errMessage = e.getMessage();
     errMessage = errMessage.replace("'","");
@>
BEGIN
-- The SQL that I want to run
<@
out.println(out_SQL);
@>
-- Error handling
<@ if ( out_SQL.length() ==0 ) { @>
     raise_application_error(-20101, '<@=errMessage@>');
<@ } else { @>
     dbms_output.put_line('Successful.');
<@ } @>     
END;
------

Please understand that I know that I can do this all within PL/SQL -- I am explicitly doing it the way I have outlined because I want to better understand the parsing levels/behavior within ODI procedures and I want to understand why KMs steps behave differently.
Another observation -- putting this all within a pl/sql block prevents ODI from properly capturing insert/update/delete row counts like it would if it were running a SQL statement.
So the question remains -- is there a way to run a dynamic SQL statement in an ODI procedure where the SQL statement is generated from within an Oracle procedure call and then run as SQL within an ODI procedure step? Best would be if there is an example of how this can be done.

Similar Messages

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

  • 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 run the SQL Script in SQL Prompt?

    Hi ExpertGroup,
    I have written one SQL Script name called "MySQLSCript.SQL". I want to know how to run the SQL Script in SQL Prompt?.
    Generally, I run SQL Script in PL/SQL Developer tool. But In this case, some SET command is not working/supporting in PL/SQL Developer Tool.
    Let me know, How to Run in SQl Prompt.
    Thanks & Regards,
    Senthil K Kumar.

    This is my SQL Script....
    SET COLSEP '|'
    SET LINESIZE 32767
    SET PAGESIZE 50000
    /* SET LINESIZE 3000
    SET PAGESIZE 50000
    SET DEFINE OFF */
    SET ECHO OFF
    SET FEEDBACK OFF
    --SET HEADING OFF
    SET TRIMSPOOL ON
    SET NEWPAGE NONE
    SET UNDERLINE OFF
    SPOOL &&EnterPath;
    SELECT * FROM &&TableName;
    SPOOL OFF
    SET FEEDBACK ON
    --SET DEFINE ON
    PROMPT Done.
    I am able to run this script in SQL Prompt....
    Its executing fine...
    But, If I am executing again it maynot asking for new set of data....
    alternativily its taking old values only.....
    how can i exeute with new set of data in the sql prompt.....

  • How to run a SQL manually with the same SQL_ID

    I want to know how to run a SQL which comes from application side manually so that same SQL_ID is generated. I am aware that even if there is a small change in the sql(even a space) the sql_id gets changed. CURSOR_SHARING_PARAMETER is similar in my DB.
    Thanks
    Rudresh

    I think you really want is the execution plan (plan_hash_value), what about outlines ?
    HTH
    Antonio NAVARRO

  • How to run batch file from oracle forms 9i

    Hi everyone.
    i have a data in csv file. i want to upload it to my database. i am using sql loader for it.
    i have made a batch file which run the sql loader and transfer my data to database.
    How to run batch file from oracle forms 9i.
    when i press the button, nothing uploads in my database. (when i simply run the batch file it works).
    here is my code
    Begin
    HOST('C:\temp\batchfile.bat');
    message('done');
    end;
    Thanks in advance
    regards
    sajid

    this is my log file, when i run manually.
    SQL*Loader: Release 10.2.0.1.0 - Production on Thu Jul 1 23:27:53 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Control File: file_to_upload.ctl
    There are 2 data files:
    Data File: sk.csv
    Bad File: sk.bad
    Discard File: none specified
    (Allow all discards)
    Data File: sk1.csv
    Bad File: sk1.bad
    Discard File: none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array: 64 rows, maximum of 256000 bytes
    Continuation: none specified
    Path used: Conventional
    Table KHAN, loaded from every logical record.
    Insert option in effect for this table: APPEND
    Column Name Position Len Term Encl Datatype
    SR FIRST * , O(") CHARACTER
    DATES NEXT * , O(") CHARACTER
    AGENT NEXT * , O(") CHARACTER
    COUNTRY NEXT * , O(") CHARACTER
    TRANSACTIONS NEXT * , O(") CHARACTER
    PKR NEXT * , O(") CHARACTER
    USD NEXT * , O(") CHARACTER
    BANK NEXT * , O(") CHARACTER
    Table KHAN:
    11088 Rows successfully loaded.
    0 Rows not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
    Space allocated for bind array: 132096 bytes(64 rows)
    Read buffer bytes: 1048576
    Total logical records skipped: 0
    Total logical records read: 11088
    Total logical records rejected: 0
    Total logical records discarded: 0
    Run began on Thu Jul 01 23:27:53 2010
    Run ended on Thu Jul 01 23:27:54 2010
    Elapsed time was: 00:00:00.63
    CPU time was: 00:00:00.17

  • Run PL/SQL from Unix

    Can anybody tell me how to run PL/SQL Procedure from unix prompt.

    You can start a sqlplus script from unix prompt, e.g.
    sqlplus <youruser>/<yourpassword>@<yourdb> @yourscript.sqlEdited by: hm on 01.01.2011 02:33

  • How to run a report from oracle 10g form in .csv format

    dear all,
    how to run a report from oracle 10g form in .csv format? i've already run in pdf & excel format.
    i'm using
    SET_REPORT_OBJECT_PROPERTY (ro_report_id, report_desformat, 'PDF'); --for pdf
    SET_REPORT_OBJECT_PROPERTY (ro_report_id, report_desformat, 'SPREADSHEET'); ---for excel
    Please Help..

    i have already tried.
    but the report show in htm or html format. that file will not save into csv. please help.

  • How to run java program from website?

    Hello
    I'd like to know how to run java program from my web page.
    I'd like to push some button in this web page so java program that would be on my server
    would pop-up. Can it be done automaticaly upon running this web site? (without any buttons - I just enter website and program pops up).
    Cheers

    I rather thought about RMI. But I could try servlets. So how it would look like?.
    I would make http request in browser (enter address) and program would show up in its window?. And I would not have to change anything in my program?. This program would run then on both boxes?. One remotely and one not?.
    But I would have to learn some basics, I've never worked with servlets. Could you suggest some good sites about it?. With ready examples so I could tweak them to my purpose.
    Message was edited by:
    macmacmac

  • How to run ZAC CDP from a Linux Bundle

    Hi all,
    I am trying to work out how to run "ZAC CDP" from a Linux bundle. We have 330 Satelites that I need to force the replication of the TFTP folder too in one staggered process.
    Is there any reason why this would not work? would a script do it and anyone have a sample?
    cheers,
    Trev.

    I would imagine it's possible.
    I'm assuming something (run as root user?)
    #!/bin/bash
    zac cdp
    (you may have to put the absolute path in for the location of "zac")
    I'm not a linux guru by any means, just that if you can script this via a cron job, I'm sure it can be done via ZCM Bundle.

  • How to run db.xml from ORPOS 13.4 version on standalone

    Hi All,
    How to run db.xml from ORPOS 13.4, We dont have ORBO.
    Thanks & Regards
    GM

    Go to the location where your installer is residing and execute the following command:
    install.cmd ant install-database
    Regards,
    Uttam Kumar

  • How do run my library from an external drive?

    How do run my library from an external drive? I've tried changing destination locations but nothing seems to work. help please

    You might find this article useful, there's a section in it on moving to an external drive:
    iLounge - Transferring your iTunes Library to Another Drive

  • How to run PL/SQL commands in this SQL browser

    How to run PL/SQL commands in this SQL browser

    This discussion should help Re: my pl/sql codes does not run in express edition what can i do????

  • How to run wfstatus.sql  for i-Expenses

    how to run wfstatus.sql for i-Expenses in 11i EBS.

    Pl see MOS Doc 295078.1 (Maintenance Pack, Patchset, and Rollup Patch Level for Internet Expenses 11i)
    HTH
    Srini

  • Dynamic SQL and Oracle stored procedures

    Does anybody has any experience with invoking an Oracle stored procedures
    with output parameters, using dynamic SQL from Forte?
    Thanks,
    Dimitar

    I would be interested. We are currently using a homegrown DataMapper architecture with the Microsoft OracleClient. I would like to move to ODP.Net once a production version supporting ADO.Net 2.0 is available. After that, I would then like to look at using an off the shelf persistence framework such as EntitySpaces, NHibernate or IdeaBlade's DevForce.

Maybe you are looking for