Calling a package function inside a sql

Hi friends!!!
First of all happy Christmas! And them please help! :)
We have a query calling a package function:
SELECT * FROM DW025H WHERE DW025H_NR=MPPCI.ENCR ('0000000000000000');There is a primary key just with one column DW025H_NR and the problem is that is not accessing by INDEX UNIQUE SCAN,
it's accessing by TABLE ACCESS FULL.
May be the problem is that we are calling a procedure inside the query?
I have been able to run that query accessing by primary key from my computer but a workmate hasn't!
We both are connecting the same data base 10.2.0.4 and using Oracle SQL Developer!
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5343K| 1406M| 15670 (7)| 00:02:43 |
|* 1 | VIEW | DW025H | 5343K| 1406M| 15670 (7)| 00:02:43 |
|* 2 | FILTER | | | | | |
| 3 | TABLE ACCESS FULL| DW025H | 5343K| 1406M| 15670 (7)| 00:02:43 |
Predicate Information (identified by operation id):
1 - filter("DW025H_NR"="MPPCI"."ENCRIPTAPAN"('0000000000000000'))
2 - filter(CASE "OPS$SISINFO"."IS_USER_DNI"() WHEN 1 THEN
SYS_AUDIT('OPS$SISINFO','DW025H','CMINFOGR001',3) ELSE NULL END IS
NULL)
The correct path would be:
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 276 | 3 (0)| 00:00:01 |
|* 1 | FILTER | | | | | |
| 2 | TABLE ACCESS BY INDEX ROWID| DW025H | 1 | 276 | 3 (0)| 00:00:01 |
|* 3 | INDEX UNIQUE SCAN | PK_DW025H | 1 | | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(CASE "OPS$SISINFO"."IS_USER_DNI"() WHEN 1 THEN
SYS_AUDIT('OPS$SISINFO','DW025H ','CMINFOGR001',3) ELSE NULL END IS NULL)
3 - access("DW025H_NR"="MPPCI"."ENCR"('0000000000000000'))
Please any ideas!?!?!
Thanks a lot!
José
Edited by: jamv on Dec 20, 2011 10:50 AM

Hello
Have a read of this and try to pull together the information in it and post it up here. That will help immensely with getting to the root of your problem...
HOW TO: Post a SQL statement tuning request - template posting
In the mean time:
From the execution plan you have extra predicates that aren't present in the query you supplied, so that's either not the SQL or you have something like VPD switched on.
Anyway, there could be lots of reasons for the difference in execution plan. Sorry if this is very basic and possibly patronising question but it's always worth checking the basics I think - are you both definitely connecting to the same database? If so, have a look in v$sqlarea for this SQL statement and find the SQL_ID, use this to query v$sql and look at the child_number column.
select
    sql_id
from
    v$sqlarea
where
    sql_text like '%SELECT * FROM DW025H WHERE DW025H_NR=MPPCI.ENCR%(''0000000000000000'')%'
and
    sql_text not like '%v$sqlarea%'
select child_number from v$sql where sql_id='<enter the sql id returned by the query above>'as an example...
XXXX> select /* my sql statement*/ rownum id from dual;
        ID
         1
1 row selected.
Elapsed: 00:00:00.10
XXXX> select sql_id from v$sqlarea where sql_text like '%my sql statement%'
and sql_text not like '%v$sqlarea%';
SQL_ID
a6ss4v79udz6g
1 row selected.
Elapsed: 00:00:03.56
XXXX> select child_number from v$sql where sql_id='a6ss4v79udz6g'
  2  /
CHILD_NUMBER
           0
1 row selected.   If you have more than one row in v$sql there could be differences in the optimiser environment. The supplied like shows you how to gather the information that should help find what the differences are if any.
Also as a side note if you're calling PL/SQL functions from SQL, you can take advantage of subquery caching to help reduce the number of calls (depending on your version). As it stands, your function is most likely going to be called for every row - when there is only a single row returned, that's not necessarily a problem but for multiple rows, the overhead can quickly grow. If there's no way to get rid of the function call, select the function from dual instead i.e.
SELECT * FROM DW025H WHERE DW025H_NR= (SELECT MPPCI.ENCR%('0000000000000000') FROM dual);This also (as I learnt a couple of weeks ago) works when you're using columns in the table your selecting from as parameters to the function.
HTH
David

Similar Messages

  • How to debug a Package / function in PL SQL developer ??

    How can we debug a Package / function in PL SQL developer ??
    i want to debug a code line by line

    Karthick_Arp wrote:
    This question does not belong to this fourm. We have a {forum:id=260} forum for such question.Not even there Karthick. PL/SQL Developer is a 3rd party tool, not Oracle's SQL Developer, so it doesn't even belong on the Oracle forums.

  • Calling public package functions and variables through dblink

    Is it possible to call a global public variable in a package in one database from another package procedure in another database using a database link? If so, could you let me know the syntax? Same question for package functions.

    Hi,
    check this documentation link especially the stmt...
    http://www.mcs.csueastbay.edu/support/oracle/doc/10.2/appdev.102/b14251/adfns_packages.htm#i1007858
    You cannot access remote package variables and constants.May be you can write a function in the remote db which when called will return the variable value.
    for calling remote package functions...
    syntax from documentation is [[schema.]package.]function_name[@dblink][(param_1...param_n)]
    an example given in the above link for this...
    EXECUTE fire_emp1@boston_server(1043);
    Ravi Kumar
    Edited by: ravikumar.sv on Aug 31, 2009 11:29 AM

  • How to call proceduer or function inside LOV of oracle apex

    Hi all,
    how to write statement to call proceduer or function inside LOV of oracle apex?
    Edited by: akki.kumar on Sep 2, 2010 12:25 AM

    Hi,
    Example how call procedure inside dynamic LOV and retrun lov from emp table
    DECLARE
    BEGIN
    my_procedure;
    RETURN 'SELECT ename d, empno r FROM emp';
    END;Regards,
    Jari
    Edited by: jarola on Sep 2, 2010 10:42 AM

  • Use a package function inside a select of the same package

    Hi.
    How can i use a function defined inside a package, with a select used inside that same package ?
    Example
    ... package example
    CREATE OR REPLACE PACKAGE BODY pkg_example
    AS
         FUNCTION sum_two_values(p_val1 NUMBER,p_val2 NUMBER) RETURN NUMBER
         IS
         BEGIN
         RETURN p_val1 + p_val2;
         END sum_two_values;
         FUNCTION use_another_function_example RETURN VARCHAR2
         IS
         v_value NUMBER;
         BEGIN
         SELECT sum_two_values(2,2) INTO v_value FROM dual;
         RETURN 'waaaazzzzupppppp'
         END use_another_function_example;
    END pkg_example;
    This will not work
    -- SELECT sum_two_values(2,2) INTO v_value FROM dual;
    How can i call a function inside a select statement, a function of the same package where the query is being called.
    (i have Oracle 9.2x)
    Cheers.

    are you sure? you are not using package1, you are using pack1
    SQL> CREATE OR REPLACE PACKAGE package1
      2  IS
      3     FUNCTION f1
      4        RETURN NUMBER;
      5 
      6     FUNCTION f2
      7        RETURN NUMBER;
      8  END;
      9  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY package1
      2  IS
      3     a   NUMBER;
      4 
      5     FUNCTION f1
      6        RETURN NUMBER
      7     IS
      8     BEGIN
      9        RETURN 1;
    10     END;
    11 
    12     FUNCTION f2
    13        RETURN NUMBER
    14     IS
    15     BEGIN
    16        SELECT package1.f1
    17          INTO a
    18          FROM DUAL;
    19 
    20        RETURN a;
    21     END;
    22  END;
    23  /
    Package body created.
    Why not just this
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE OR REPLACE PACKAGE BODY package1
      2  IS
      3     a   NUMBER;
      4     FUNCTION f1
      5        RETURN NUMBER
      6     IS
      7     BEGIN
      8        RETURN 1;
      9     END;
    10     FUNCTION f2
    11        RETURN NUMBER
    12     IS
    13     BEGIN
    14        a:= f1;
    15 RETURN a;
    16     END;
    17* END;
    SQL> /
    Package body created.formatted
    Message was edited by:
    devmiral

  • Error calling a package function

    Hi all,
    I've created one package and inside it, I've two different functions. The package definition and body are OK.
    Now, I want use it but, I've an error:
    ORA-06550: line 16, column 13:
    PLS-00201: 'BB.PKG_BB_TEMP' must be declared
    this is the function declaration on package declaration:
    FUNCTION busca_municipio (gest varchar2) RETURN number;
    Procedure solu (codi_ges number, muni number);
    And this is the code from I'm calling:
    DECLARE
    CURSOR datos IS
    select a.id from bb.cr_agent a, bb.cr_branchoffice b, bb.cr_professionalorder p, bb.cr_user u where a.branchoffice_id = b.id
    and b.professionalorder_id = p.id and p.externalsystem_id = 42 and a.id = u.id and u.address_id is null;
    cod_ag number;
    muni number;
    BEGIN
    muni:=0;
    open datos;
    loop
    fetch datos into cod_ag;
    exit when datos%notfound;
    muni:=bb.pkg_bb_temp.busca_municipio(cod_ag);
    bb.pkg_bb_temp.solu (cod_ag,muni);
    end loop;
    close datos;
    END;
    This package is owned by user BB, and I'm connected like sys to execute the code I put before.
    Any ideas?
    Regards,
    dbajug

    dbajug wrote:
    Hi all,
    I'm having problems to grant:
    SQL> select object_name, object_type, status from dba_objects where owner like 'BB' and object_type like 'PACK%';
    OBJECT_NAME OBJECT_TYPE STATUS
    PKG_bb_temp PACKAGE VALID
    PKG_bb_temp PACKAGE BODY VALID
    SQL> GRANT EXECUTE ON BB.PKG_bb_temp to sys;
    GRANT EXECUTE ON BB.PKG_bb_temp to sys
    ERROR in line 1:
    ORA-04042: procedure, function, package or package body doesn't exist
    SQL> conn bb/*******
    Conected.
    SQL> GRANT EXECUTE ON PKG_bb_temp to sys;
    GRANT EXECUTE ON PKG_bb_temp to sys
    ERROR in line 1:
    ORA-04042: procedure, function, package or package body doesn't exist
    Any ideas?
    Regards,
    dbajugHave you created the package with a case sensitive name i.e. did you put double quotes around it?
    select owner, object_name from all_objects where upper(object_name) = 'PKG_BB_TEMP';The owner should show as "BB" and the object_name should be in upper case (hopefully). If it's not upper case then it's been created case sensitive and you you'll have to either recreate the package without using double quotes around the name or make sure you always reference the package with double quotes and the case exact version of the name.
    e.g.
    GRANT EXECUTE ON "PKG_bb_temp" TO <user>;Hopefully, you are not running your other code as SYS, so you should ensure you grant permission to the correct user, not to SYS.

  • Calling Oracle Package Function from Visual Basic

    Hi,
    Oracle Client 8.04
    Oracle ODBC Driver 8.00.04
    VB 6.0
    Windows 2000
    I'm stumped here. I want to have a Oracle stored procedure run a
    query and return a result set which I can assign to a recordset
    object in VB. Based on things I've read here and on MS's site,
    here's what I've done:
    In the Oracle Schema Manager under the Packages folder I created
    the following package:
    PACKAGE test
    IS
    TYPE test_cur IS REF CURSOR;
    FUNCTION mycur RETURN test_cur;
    END test;
    and under the Package Body folder created:
    PACKAGE BODY test
    IS
    FUNCTION mycur RETURN test_cur
    IS
    c_return test_cur;
    BEGIN
    OPEN c_return FOR
    SELECT * FROM table_A;
    RETURN c_return;
    CLOSE c_return;
    END mycur;
    END test;
    They both compile without errors and in Oracle SQL Worksheet I
    can enter the following:
    variable x refcursor;
    execute :x :=test.mycur;
    print x;
    and the query results are displayed as expected.
    The problem is trying to get the result back into a VB recordset
    object.
    In VB 6.0 I have done this:
    Dim RS As ADODB.Recordset
    Dim Conn As ADODB.Connection
    Dim sConnection As String
    Dim sSQL As String
    sSQL = "{call test.mycur}"
    sConnection = "Provider=MSDASQL;UID=" & sUserID & ";PWD=" &
    sPassword & ";Driver={Microsoft ODBC for Oracle}; Server=" &
    sInstance & ";"
    Conn.Open sConnection
    RS.CursorLocation = adUseClient
    RS.Open sSQL, Conn, adOpenForwardOnly, adLockOptimistic,
    adCmdStoredProc ' or adCmdText
    but get:
    ?err.Number -2147217900
    ?err.Source Microsoft OLE DB Provider for ODBC Drivers
    ?err.Description [Microsoft][ODBC driver for Oracle]Syntax error
    or access violation
    The problem is not with the connection or permissions, since the
    query works fine when I just use the select statement in the
    package function as the string, instead of calling the function
    in the package (eg sSQL = "Select * from table_A") and can
    process the resulting recordset in VB.
    I've also tried variations using:
    Set RS = Conn.Execute("{call test.mycur}")
    or using a Command object something like:
    Dim com As ADODB.Command
    Set com = New ADODB.Command
    With Conn
    .ConnectionString = sConnection
    .CursorLocation = adUseClient
    .Open
    End With
    With com
    .ActiveConnection = Conn
    .CommandText = sSQL
    .CommandType = adCmdText
    End With
    Set RS.Source = com
    RS.Open
    But still get the same errors. Any help is appreciated. Also, in
    my package body, is it necessary to explicitly close the cursor,
    or does the function just exit when it executes the return and
    not ever hit the close statement?
    Thanks,
    Ed Holloman

    Hi
    i don't know if you got your answer, but i work with VB and
    Oracle.
    the procedure in the DB should have the cursor like you writen
    in your mail.
    to call a procedure in Oracle and get the data back
    into a recordset you shuld use a Command object like this:
    Dim conn As ADODB.Connection
    Dim cmd As ADODB.Command
    Dim rs As ADODB.Recordset
    Set conn = CreateObject("adodb.connection")
    Set cmd = CreateObject("adodb.command")
    Set rs = CreateObject("adodb.recordset")
    With conn
    .ConnectionString = ""
    .CursorLocation = adUseClient
    .Open
    End With
    'THE IMPORTENT SECTION IS THIS WHERE YOU SET THE COMMAND TO THE
    STORE PROCEDURE TYPE
    With cmd
    .ActiveConnection = conn
    .CommandText = "proc.fun"
    .CommandType = adCmdStoredProc
    End With
    'Then you set the rs to the command
    Set rs = cmd.Execute
    Set conn = Nothing
    Set rs = Nothing
    Set cmd = Nothing

  • Calling a package function in the data template

    Hello All,
    I am not able to understand the concept of calling a function from the data template.
    In my data template, I put the sql statement as
    <sqlStatement name="Q_SEL">
    <![CDATA[  Select l_period_name PERIOD_NAME
                             from xla_tb_ap_report_pvt.get_period_name(1) ]]>
    </sqlStatement>
    Is it possible to call a specific package function as shown above in a select statement?
    I am getting the message "ORA-00933: SQL command not properly ended" when I tried with the above. Could you pls. point out what the error is in the above sqlStatement?
    1) My instance is R12.1.3
    2) The base pkg function 'xla_tb_ap_report_pvt.get_period_name' expects a number to be passed in as 'IN' parameter.
    Thanks,
    Monkey

    I tried another version of the sql statement (after going through some older posts) like:
    <sqlStatement name="Q_SEL">
    <![CDATA[  Select xla_tb_ap_report_pvt.get_period_name(1) PERIOD_NAME
                            from  dual]]>
    </sqlStatement>
    My group is :
    <group name="G_PERIOD_NAME" source="Q_SEL">
    <element name="PERIOD_NAME" value="PERIOD_NAME"/>
    </group>
    Now getting the error message:
    ORA-00904: xla_tb_ap_report_pvt.get_period_name : invaild identifier
    What is it that i am doing wrong?
    Thanks,
    Monkey
    Edited by: OAF_Monkey on Mar 26, 2012 11:52 AM

  • Calling an HTML function from PL/SQL stsement

    The pl/sql statement below is in attempt to raise an alert window whenever a new record is added to the database by an automatic page refresh.
    Pls help me edit the statement below to call a HTML function named attention()from within the pl/sql statement or better still review the stuff to achieve the objective.
    declare
    v_count number;
    attention varchar2(100);
    begin
    select count(move_id)
    into v_count
    from move
    where move_status = 'Approved';
    if v_count > :f100_move_count then
    attention();
    end if;
    end;
    Thanks gents
    Sirdeeq

    Sorry, the function is Javascript not HTML

  • Calling SSIS package from DTEXEC in SQL Server 2012

    Hello,
    I have a package called test.dtsx developed in SSIS vs 2010 (project deployment model). It has two project parameters one is  db connection (string) and one is classnumber(string). This package has been deployed as file system and in SSISDB. I want to
    assign the following values to the project parameters
    $Project::DBConnection - Data Source=localhost;User ID=User;Password=password;Initial Catalog=testdb;Provider=SQLNCLI11.1;Persist Security Info=True;Auto Translate=False;
    $Project::Classnumber - 10
    What is the syntax to call this package from dtexec passing values for parameters
    1. as a file system deployment
    2. as a package in SSIS db(catalog)
    thanks

    http://msdn.microsoft.com/en-ca/library/hh231187.aspx has an example
    Dtexec /isserver “SSISDB\MyFolder\MyProject\test.dtsx” /server “.” /parameter $Project::DBConnection;thevalue /parameter anotherparam(int32);12
    Arthur My Blog

  • Unable to call a Packaged function in SQL statement??

    I have written a package & overloaded a function 3 times. I am using different parameter name for overloading & call as follows:
    my_pkg.ovrld_func(p_1 => v_val)
    my_pkg.ovrld_func(p_2 => v_val)
    my_pkg.ovrld_func(p_3 => v_val)
    When i use this statement in a sql or DML statement i get the following error.
    ORA-00907: missing right parenthesis
    I searched for limitations on packages but couldn't find this issue.
    FYI: I am using Oracle 9i Rel2
    Thanks

    I think its a bug as Oracle didn't report this limitation anywhere in the documentation & i should open a TAR.Well, it's documented limitation in fact.
    Quote "Oracle9i Application Developer’s Guide - Fundamentals Release 2 (9.2)"
    In a chapter entitled "Syntax for SQL Calling a PL/SQL Function"
    p. 9-53.
    Arguments
    To pass any number of arguments to a function, supply the arguments within the
    parentheses. You must use positional notation; named notation is not currently
    supported. For functions that do not accept arguments, use ().Regards.

  • Calling a Java Function from PL/SQL

    Hi,
    I would like to call a Java API from a java class residing on the middle tier ($OA_JAVA)
    from the subscription code of a business event. The business event will have a
    subscription with java rule function as my Java API. And the business event will be
    raised from PL/SQL code using WF_EVENT.RAISE API. I want the Java API to
    executed SYNCHRONOUSLY without deferring the event. Can you please provide
    pointers to this.
    Regards
    Ramesh

    Documentation here: http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref185
    says JPublisher can publish records too.
    But when I change the example given at http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref190 as following:
    PACKAGE "COMPANY" AS
    type emp_rec is record (empno number, ename varchar2(10));
    type emp_list is varray(5) of emp_rec;
    type factory is record (
    name varchar(10),
    emps emp_list
    function get_factory(p_name varchar) return factory;
    END;
    then I see <unknown type or type not found> at sql or java files generated. Any ideas?

  • Problem calling a packaged function from an authorization scheme

    I wrote a package and body called pkg_auth with a function returning a boolean called is_authorized with 2 parameters (username and functional area).
    i.e.
    CREATE OR REPLACE PACKAGE pkg_auth
    AS
    FUNCTION is_authorized(p_username VARCHAR2, p_functional_area VARCHAR2) RETURN BOOLEAN;
    END;
    additionally i created a public synonym for it and granted execute access on it to apex_public_user and htmldb_public_user;
    i then created an authorization scheme called 'access_control_db' defined as Scheme Type 'PLSQL Function Returning Boolean' and placed the following:
    pkg_auth.is_authorized(v('APP_USER'),'DATABASE')
    in the Expression 1 field.
    and the following:
    Not permitted to edit database information.
    in the error field.
    However when I apply this authorization scheme to a buton I receive the following error when I go to the page containing that button:
    ORA-06550: line 1, column 44: PLS-00221: 'IS_AUTHORIZED' is not a procedure or is undefined ORA-06550: line 1, column 44: PL/SQL: Statement ignored
         Error      ERR-1082 Error in executing authorization scheme code.
    Any help would be most appreciated.

    Hello,
    Does putting 'return' infront -
    return pkg_auth.is_authorized(v('APP_USER'),'DATABASE')fix your problem?
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • Error when calling a package function

    any insight why my object is erroring out when calling a function. the error is
    oracle.apps.fnd.framework.OAException: java.sql.SQLException: ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    ORA-06512: at line 1
    it errors out when the cs.execute() is . is it the placement ? thanks for the help....
    then pkg func is xxx.get_log
    Get_Log(rmode IN NUMBER , doc_type IN VARCHAR2 DEFAULT 'TEL', doc_id IN VARCHAR2 DEFAULT NULL,
    doc_num IN VARCHAR2 DEFAULT NULL -- , p_out out varchar2 --
    RETURN varchar2 IS....
    the co
    Serializable paramDocLocatorParamList [] = {paramRMODE, paramDOC_TYPE, paramDOC_ID, paramDOC_NUM, p_out };
    OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
    OADBTransaction dbtrans;
    OAViewObject docLocator = (OAViewObject)am.findViewObject("DocLocatorVO1");
    rtxt0.setValue(pageContext, "here it is" + am.invokeMethod("getHTMLString", paramDocLocatorParamList));
    docLocator.executeQuery();
    // am.invokeMethod("getHTMLString", paramDocLocatorParamList);
    the impl
    public String getHTMLString ( String paramRMODE, String paramDOC_TYPE, String paramDOC_ID, String paramDOC_NUM, String p_out )
    System.out.println("Entering The AM Impl");
    CallableStatement st = null;
    OADBTransaction txn = (OADBTransaction)getDBTransaction();
    Connection conn = txn.getJdbcConnection();
    String sql = " BEGIN :5 := test_proc.get_log(:1, :2, :3, :4 ); END; ";
    CallableStatement cs = txn.createCallableStatement(sql,1);
    String ErrorExist = "";
    String getHTML = "";
    try
    cs.setString(1, paramRMODE);
    cs.setString(2, paramDOC_TYPE);
    cs.setString(3, paramDOC_ID);
    cs.setString(4, paramDOC_NUM);
    cs.setString(5,p_out); // --param   
    /* cs.registerOutParameter(1,Types.CHAR);
    cs.registerOutParameter(2,Types.CHAR);
    cs.registerOutParameter(3,Types.CHAR);
    cs.registerOutParameter(4,Types.CHAR);*/
    cs.registerOutParameter(5,Types.CHAR);
    cs.execute();
    getHTML = cs.getString(5 ) ;
    /* System.out.println("getHTML is " + getHTML );
    cs.close();
    // if ( "E".equals(ErrorExist))
    /// throw new OAException ("Payment Request Is Already Cancelled" );
    catch (SQLException sqle)
    try { cs.close(); }
    catch (Exception e) {}
    throw OAException.wrapperException(sqle);
    String doctype = paramDOC_TYPE;
    String docnum = paramDOC_NUM;
    String html ;
    System.out.println( "paramDOC_TYPE in IMPL is " + doctype) ;
    System.out.println( "paramDOC_Numb in IMPL is " + docnum) ;
    return getHTML;

    resolved.....
    public String getHTMLString (String p_out , String rmode, String doc_type, String doc_id, String doc_num )
    System.out.println("");
    System.out.println("Entering The AM Impl");
    // System.out.println("Passing getDocAbbrForHTML in IMPL -------> " +getDocAbbrForHTML     );
    // System.out.println("Passing paramDOC_NUM in IMPL -------> " + paramDOC_NUM );
    System.out.println("Passing getDocAbbrForHTML in IMPL -------> " +doc_type     );
    System.out.println("Passing paramDOC_NUM in IMPL -------> " + doc_num );
    CallableStatement st = null;
    OADBTransaction txn = (OADBTransaction)getDBTransaction();
    Connection conn = txn.getJdbcConnection();
    String sql = " BEGIN :1 := test_proc.get_log(:2, :3, :43, :5 ); END; ";
    CallableStatement cs = txn.createCallableStatement(sql,1);
    String ErrorExist = "";
    String getHTML = "";
    try
    cs.setString(2, rmode);
    cs.setString(3, doc_type);
    cs.setString(4, doc_id);
    cs.setString(5, doc_num);
    cs.registerOutParameter(1,Types.VARCHAR);
    cs.execute();
    getHTML = cs.getString(1 ) ;

  • Calling the package dynamically inside a procedure

    HI
    i have table which contains contains package name, procedurename,input parameters and output parameters as columns like below.
    Table name is PKG_META_DATA.
    package_name Procedure_name input parameters output parameters
    pkg1 prc1 i_location,i_type o_date
    pkg2 prc3 i_location o_date ,o_prev_date
    Note:Input parameters and output parameters will vary according to package
    Now i need to write a procedure which calls package dynamically and display the output values.
    i have tried it in this way but it it is not working.please help
    declare
    l_text varchar2(1000);
    cursor c1 is select package_name,Procedure_name,input parameters,output parameters from pkg_meta_date;
    begin
    for cur in c1 loop
    execute immediate 'begin '||package_name||'.'||Procedure_name||'('||input parameters ||output parameters||');'
    --display output values from a package
    dbms_output.put_line( o_date );
    dbms_output.put_line( o_prev_date );
    end loop;
    end;

    user12057782 wrote:
    Now i need to write a procedure which calls package dynamically and display the output values.Why do such a silly and stupid thing? Do you have technical justification for wanting to call code dynamically?
    And if you reallly and truly need to use dynamic PL/SQL calls, then using bind variables is mandatory. Unless you want to fragment and trash the shared pool and waste a lot of CPU by burning it on hard parsing.
    This also means that execute immediate is the wrong choice. (it does not support dynamic binding)
    And if I foam a bit at the mouth with this response - simply that I'm getting utterly frustrated seeing yet again dynamic SQL being (ab)used, without the foggiest notion of how to do so correctly, and with complete ignorance of the repercussions on security and performance.
    Dynamic coding is NOT the best thing since slice bread. It was never even a consideration as a being better choice.
    What it is, is wrong - 99% of the time. Wrong ito design. Wrong for security. Wrong for performance. Wrong for flexibility.

Maybe you are looking for