Call a function in a package body

I am new to Oralce, I am tried to call a function in an exiting package body using the package specification. function.
But it failed , it says wrong numbers or types of parameters. I see the functions are defined in the package body with two definitions but different numbers of parameters. One has only one parmenter, the other has 3.
But in the packgage definition is has the function with one parameter.
So when I call using 3 parameters, it gives the error.
Why is that?
Thanks

875563 wrote:
I am new to Oralce, I am tried to call a function in an exiting package body using the package specification. function.
But it failed , it says wrong numbers or types of parameters. I see the functions are defined in the package body with two definitions but different numbers of parameters. One has only one parmenter, the other has 3.
But in the packgage definition is has the function with one parameter.
So when I call using 3 parameters, it gives the error.
Why is that?
ThanksHow do I ask a question on the forums?
SQL and PL/SQL FAQ
I don't know what you have.
I don't know what you do.
I don't know what you see.
It is really, Really, REALLY difficult to fix a problem that can not be seen.
use COPY & PASTE so we can see what you do & how Oracle responds.

Similar Messages

  • Can I call a function in another package?

    Dear all,
    Can I call a function in another package?
    Say I have package A, and package B.
    Is it possible for me to call a function in inside package A, within a function inside package B?
    If yes, what's the syntax.
    Thanks in advance!

    The variable in the calling package that will receive the value of the function in the other package needs to be defined based on that type in the other package directly:
    sql>create or replace package pkg_a
      2  is
      3    type testTable is table of varchar2(10) index by binary_integer;
      4 
      5    function f_a return testTable;
      6  end;
      7  /
    Package created.
    sql>create or replace package body pkg_a
      2  is
      3    function f_a
      4      return testTable
      5    is
      6      v_table testTable;
      7    begin
      8      v_table(1) := 'One';
      9      v_table(2) := 'Two';
    10      return v_table;
    11    end; 
    12  end;
    13  /
    Package body created.
    sql>create or replace package pkg_b
      2  is
      3    procedure p_b;
      4  end; 
      5  /
    Package created.
    sql>create or replace package body pkg_b
      2  is
      3    procedure p_b
      4    is
      5      v_table pkg_a.testTable;  -- this variable has to be based on the type in pkg_a
      6    begin
      7      v_table := pkg_a.f_a;
      8      for i in 1..v_table.count loop
      9        dbms_output.put_line( v_table(i) );
    10      end loop;
    11    end;
    12  end; 
    13  /
    Package body created.
    sql>exec pkg_b.p_b
    One
    Two
    PL/SQL procedure successfully completed.

  • How to get a called procedure/function name within package?

    Hi folks,
    is it possible to obtain a called procedure/function name within package?
    For a measuring and tracing purpose, I would like to store an info at the beginning of each procedure/function in package with timestamp + additional details if needed.
    For example:
    CREATE OR REPLACE PACKAGE BODY "TEST_PACKAGE" IS
       PROCEDURE proc_1 IS
       BEGIN
          api_log.trace_data(sysdate, 'START.' || ???????);
          api_log.trace_data(sysdate, 'END.' || ???????);
       END;
       PROCEDURE proc_2 IS
       BEGIN
          api_log.trace_data(sysdate, 'START.' || ???????);
          proc_1;
          api_log.trace_data(sysdate, 'END.' || ???????);
       END;
    END; I would like to replace "???????" with a function which would return a name of called procedure, so result of trace data after calling TEST_PACKAGE.proc_2 would be:
       11.1.2013 09:00:01    START.*TEST_PACKAGE.proc_2*
       11.1.2013 09:00:01    START.*TEST_PACKAGE.proc_1*
       11.1.2013 09:00:01    END.*TEST_PACKAGE.proc_1*
       11.1.2013 09:00:01    END.*TEST_PACKAGE.proc_2*I tried to use "dbms_utility.format_call_stack" but it did not return the name of procedure/function.
    Many thanks,
    Tomas
    PS: I don't want to use an hardcoding

    You've posted enough to know that you need to provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
    >
    is it possible to obtain a called procedure/function name within package?
    For a measuring and tracing purpose, I would like to store an info at the beginning of each procedure/function in package with timestamp + additional details if needed.
    >
    I usually use this method
    1. Create a SQL type for logging information
    2. Put the package name into a constant in the package spec
    3. Add a line to each procedure/function for the name.
    Sample package spec
          * Constants and package variables
              gc_pk_name               CONSTANT VARCHAR2(30) := 'PK_TEST';Sample procedure code in package
          PROCEDURE P_TEST_INIT
          IS
            c_proc_name CONSTANT VARCHAR2(80)  := 'P_TEST_INIT';
            v_log_info  TYPE_LOG_INFO := TYPE_LOG_INFO(gc_pk_name, c_proc_name); -- create the log type instance
          BEGIN
              NULL; -- code goes here
          EXCEPTION
          WHEN ??? THEN
              v_log_info.log_code := SQLCODE;  -- add info to the log type
              v_log_info.log_message := SQLERRM;
              v_log_info.log_time    := SYSDATE;
              pk_log.p_log_error(v_log_info);
                                    raise;
          END P_PK_TEST_INIT;Sample SQL type
    DROP TYPE TYPE_LOG_INFO;
    CREATE OR REPLACE TYPE TYPE_LOG_INFO AUTHID DEFINER AS OBJECT (
    *  NAME:      TYPE_LOG_INFO
    *  PURPOSE:   Holds info used by PK_LOG package to log errors.
    *             Using a TYPE instance keeps the procedures and functions
    *             independent of the logging mechanism.
    *             If new logging features are needed a SUB TYPE can be derived
    *             from this base type to add the new functionality without
    *             breaking any existing code.
    *  REVISIONS:
    *  Ver        Date        Author           Description
    *   1.00      mm/dd/yyyy  me               Initial Version.
        PACKAGE_NAME  VARCHAR2(80),
        PROC_NAME     VARCHAR2(80),
        STEP_NUMBER   NUMBER,
        LOG_LEVEL   VARCHAR2(10),
        LOG_CODE    NUMBER,
        LOG_MESSAGE VARCHAR2(1024),
        LOG_TIME    TIMESTAMP,
        CONSTRUCTOR FUNCTION type_log_info (p_package_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_proc_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_step_number IN NUMBER DEFAULT 1,
                                            p_LOG_level IN VARCHAR2 DEFAULT 'Uninit',
                                            p_LOG_code IN NUMBER DEFAULT -1,
                                            p_LOG_message IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_LOG_time IN DATE DEFAULT SYSDATE)
                    RETURN SELF AS RESULT
      ) NOT FINAL;
    DROP TYPE BODY TYPE_LOG_INFO;
    CREATE OR REPLACE TYPE BODY TYPE_LOG_INFO IS
        CONSTRUCTOR FUNCTION type_log_info (p_package_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_proc_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_step_number IN NUMBER DEFAULT 1,
                                            p_LOG_level IN VARCHAR2 DEFAULT 'Uninit',
                                            p_LOG_code IN NUMBER DEFAULT -1,
                                            p_LOG_message IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_LOG_time IN DATE DEFAULT SYSDATE)
         RETURN SELF AS RESULT IS
        BEGIN
          self.package_name  := p_package_name;
          self.proc_name     := p_proc_name;
          self.step_number   := p_step_number;
          self.LOG_level   := p_LOG_level;
          self.LOG_code    := p_LOG_code;
          self.LOG_message := p_LOG_message;
          self.LOG_time    := p_LOG_time;
          RETURN;
        END;
    END;
    SHO ERREdited by: rp0428 on Jan 11, 2013 10:35 AM after 1st cup of coffee ;)

  • Need Help: Using Ref Cursor in ProC to call a function within a Package

    I'm calling a function within a package that is returning a REF CURSOR.
    As per the Oracle Pro*C Programmer's Guide, I did the following:
    1) declared my cursor with a: EXEC SQL BEGIN DECLARE SECTION and declared the cursor as: SQL_CURSOR my_cursor;
    2) I allocated the cursor as: EXEC SQL ALLOCATE :my_cursor;
    3) Via a EXEC SQL.....END-EXEC begin block
    I called the package function and assign the return value to my cursor
    e.g. my_cursor := package.function(:host1, :host2);
    Now, the only difference between my code and the example given in the Pro*C Programmer's Guide is that the example calls a PROCEDURE within a package that passes back the REF CURSOR as an OUT host variable.
    Whereas, since I am calling a function, the function ASSIGNS the return REF CURSOR in the return value.
    If I say my_cursor := package.function(:host1, :host2); I get a message stating, "PLS-00201: identifier MY_CURSOR" must be declared"
    If I say :my_cursor := package.function(:host1, :host2); I get a message stating, "ORA-01480: trailing null missing from STR bind value"
    I just want to call a package function and assign the return value to a REF CURSOR variable. There must be a way of doing this. I can do this easily in standard PL/SQL. How can this be done in Pro*C ???
    Thanks for any help.

    Folks, I figured it out. For those who may face this problem in the future you may want to take note for future reference.
    Oracle does not allow you to assign the return value of a REF CURSOR from a FUNCTION ( not Procedure - - there is a difference) directly to a host variable. This is the case even if that host variable is declared a CURSOR variable.
    The trick is as follows: Declare the REF CURSOR within the PL/SQL BEGIN Block, using the TYPE statement, that will contain the call to the package function. On the call, you then assign the return REF CURSOR value that the function is returning to your REF CURSOR variable declared in the DECLARE section of the EXEC SQL .... END-EXEC PL/SQL Block.
    THEN, assign the REF CURSOR variable that was populated from the function call to your HOST cursor varaible. Then fetch this HOST Cursor variable into your Host record structure variable. Then you can deference individual fields as need be within your C or C++ code.
    I hope this will help someone facing a deadline crunch. Happy computing !

  • Call a function inside a package from a stored procedure

    Hello:
    I am kind of new to the stored procedure. Does anyone know how to call a function inside a package from another stored procedure?
    I have a existing function (func_b) inside a package (pack_a) and it returns a cursor. I want to call this function from a stored procedure (proc_c) so that I use the data inside the cursor.
    can I do the following in proc_c:
    my_cursor1 SYS_REFCURSOR;
    begin
    my_cursor1 := exec pack_a.func_b
    end
    It will be very helpful if anyone can point me to any reading or example. Thank you very much for your information.

    guys:
    Thank you for your information so far. I need some more help here. I was able to run the function in my stored procedure. However, I was not able to print the result on the screen to view the cursor result, although I am using dbms_output.put_line statement inside my stored procedure.
    I use the following statement to execute my stored procedure on sql*plus. I can tell the stored procedure is executed successfully, but I did see anything printed:
    DECLARE TEMP VARCHAR2(100);
    BEGIN PROC_LAWS_CAD_NAME_SEARCH('LPD', 'TEST DEVICE ID', 'TEST LAST NAME', 'TEST FIRST NAME', 'F', '11112009', TEMP); END;
    I tried to use 'set serveroutput on' and got the following error:
    ERROR:
    ORA-06502: PL/SQL: numeric or value error: host bind array too small
    ORA-06512: at line 1
    I am kind of confused now. thank you for your help.
    Jack
    Here is my procedure:
    create or replace
    PROCEDURE PROC_SEARCH
    ( AGENCY_ID IN VARCHAR2,
    DEVICE_ID IN VARCHAR2,
    L_NAME IN VARCHAR2,
    F_NAME IN VARCHAR2,
    SEX IN VARCHAR2,
    DOB IN VARCHAR2,
    CAD_NAME_SCH_RESULT_STR OUT VARCHAR2)
    AS
    v_agy_id varchar2(10);
    v_device_id varchar2(20);
    v_l_name varchar2(25);
    v_f_name varchar2(15);
    v_sex varchar2(1);
    v_dob date;
    -- this cursor is going to be used to store a list of warrant matching
    -- name search criteria
    cad_srch_cursor sys_refcursor;
    objSrch SEARCH_RESULT_TEMP%ROWTYPE;
    BEGIN
    cad_srch_cursor := SEARCH_PKG.SEARCH('TESTING', 'TESTER', null, null,null, null, getPhonetic('TESTING'));
    LOOP
    FETCH cad_srch_cursor INTO objSrch;
    EXIT WHEN cad_srch_cursor%NOTFOUND;
    --insert into SEARCH_RESULT_TEMP (name_last) values (objSrch.name_last);
    CAD_NAME_SCH_RESULT_STR := objSrch.name_last;
    dbms_output.put_line('First:'||objSrch.name_first||':Last:'||objSrch.name_last||':Middle:'||objSrch.name_middle);
    end LOOP;
    END PROC_LAWS_SEARCH;
    -----------------------------------------

  • How do I view a FUNCTION within a Package Body

    I can see the FUNCTION being executed within the Package...
    FUNCTION Stop_Refresh_AsBilled
    RETURN Number;
    And within Oracle SQL Developer and using the Connection and "Packages" part of the Schema, I see the Function Name. However, when I <Double-Click> on the FUNCTION Name within the Schema, it is taking me to where the FUNCTION is executed within the Package and NOT to the PL/SQL Code that actually makes up the FUNCTION.
    Am I missing something here??? Maybe in my Preferences??? How can I drill down further to actually find the FUNCTION Definition and PL/SQL Code that makes up the FUNCTION within the Package Body???
    I can bring up the Package Body and Search on the FUNCTION that way. I'm hoping there is an easier way however to drill down to the actual PL/SQL Code that makes up the FUNCTION.
    I hope I am being clear in my explanation here.
    Thanks for your review and I am hopeful for a reply.
    PSULionRP

    Jim, opening the body node to see all functions and procedures sometimes does not work in 3.0
    I have many packages generated by Feuerstien's CodeGen utility. The Query package appears just fine with every function and procedure appearing as expected in both header and body nodes. However, the Change Package fails miserably. Header shows all functions and procedures fine, but the body node only shows the top private declarations of variables and types. Not one function or procedure appears in the expanded node.
    The only thing I can figure is that the Change package of about 30 named items has many of the same name+ with overloaded parameters. I think SQL Dev is having problems parsing the names in the body even though it does fine with the names in the header of the package--perhaps because of many private variables and PRAGMA's declared at the top of the body.
    Both packages have about 30 functions, but the Change package body has over 2000 lines while the Query package has fewer than 500.
    Just adding to the mystery--but I think it merits a bug report (gotta figure out where to report it now).

  • Calling oracle function defined within package from JPA

    Hi All,
    I am trying to call a function get_owner() defined under a package pkg_x_y.
    But I get an error when I do
    entityManager.createNativeQuery("call pkg_x_y.get_owner()");
    Caused by: java.sql.SQLSyntaxErrorException: ORA-00907: missing right parenthesis
    What is the correct way to execute this function?
    Thanks in advance.

    JPA 2.1 standardized stored procedure support, and is available within EclipseLink 2.5 as described here: http://wiki.eclipse.org/EclipseLink/Release/2.5/JPA21#Stored_Procedures
    If you are unable to use JPA 2.1, you can use EclipseLink's stored procedure support as described here: http://wiki.eclipse.org/EclipseLink/Examples/JPA/StoredProcedures
    The problem you are getting with your call though might be coming from within the stored proc itself, not the native query execution.  Its hard to tell - are you able to execute the query on your database directly, such as through SQLPlus?

  • How do you call a function within a package using OCI in C

    I am trying to call a user-defined function in Oracle 8.1.7 using OCI in C. I am getting a ORA-06550 PLS-00221, <function name> is not a procedure or is undefined. Can anyone tell me how I would call a function using OCI?
    Thanks.

    I think I figured it out, but I am now getting a ORA-06512 error; numeric or value error: character string buffer too small.

  • Tricky: Calling Oracle Function in an Package with DAO over ODBC

    Hello,
    our customer is using Oracle 10.2.0.3 Enterprise Edition. We've to create an interface from our Microsoft Access 2000 application to the oracle system.
    We want to call a Oracle Package-Function with DAO over ODBC.
    We are using VBA with Microsoft Access 2000 SP3.
    The ADO solution that works is:
    Public Function CallSProcADO()
    Dim cmd As ADODB.Command
    Dim cmdWrite As ADODB.Command
    Dim conn As ADODB.Connection
    Dim param As ADODB.Parameter
    On Error GoTo err_handler
    Set conn = New ADODB.Connection
    conn.Open "dsn=xxx;UID=xxx;PWD=xxx;"
    Set cmdWrite = New ADODB.Command
    cmdWrite.ActiveConnection = conn
    cmdWrite.CommandText = "{ ? = call XXX.PACKAGENAME.FUNCTION(?,?)}"
    cmdWrite.Parameters(0).Direction = adParamReturnValue
    cmdWrite.Parameters(0).Type = adInteger
    cmdWrite.Parameters(1).Direction = adParamInput
    cmdWrite.Parameters(1).Type = adVarChar
    cmdWrite.Parameters(1).Value = "C0045/2006"
    cmdWrite.Parameters(2).Direction = adParamInput
    cmdWrite.Parameters(2).Type = adVarChar
    cmdWrite.Parameters(2).Value = "J"
    cmdWrite.Execute
    conn.Close
    MsgBox "Successfull!"
    Exit Function
    err_handler:
    MsgBox "Error!"
    End Function
    Now we want to know if it's possible to use DAO to do the same.
    best regards
    Arndt

    During binding, strings are generally skipped. As such, you should first try replacing XMLType('?') with XMLType(?). You don't need to specify '?' because the system knows the proper type from your SQLBindParameter call.
    Also, you should try replacing:
    sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0,(SQLPOINTER)3, 0, &type[2]);
    with
    sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0,(SQLPOINTER)buf, BUFSIZE, &type[2]);

  • Call/start function on another package

    hi all,
    i'm new to java card development..
    i'd like to know if it's possible to call/start a function, or assign a value to a variable that belongs in an applet of a different package..
    currently, i'm using an old eclipse version for development..
    any comment is appreciated..
    thanks..
    regards,
    bayu k

    Hi Manuel,
    Thanks a lot for the hint and the link..
    I already started making 2 test packages (server and client) to try the shareable interface object, but i cant seem to get it right..
    on the client side, i cant cast the interface.. i think i need to import the server's package, but i dont know how to refer to another project.. (em using eclipse v2.1)
    below is the code.. i mark the line where i other package can not be resolved.. (commented as "PROBLEM")
    appreciate it very much for anyone's comment..
    thank you..
    server package : (1 class, 1 interface)
    the interface :
    package settings;
    import javacard.framework.*;
    public interface Settings extends Shareable
         public void SetLang(byte lang);
         public byte GetLang();
    the class :
    package settings;
    import javacard.framework.*;
    public class Proc extends Applet implements Settings {
         private byte bLang;
         public void SetLang(byte lang)
              bLang = lang;     
         public byte GetLang()
              return bLang;     
         public Shareable getShareableInterfaceObject(AID clientAID, byte parameter)
                    return this;
         public static void install(byte[] bArray, short bOffset, byte bLength) {
              // OP-compliant JavaCard applet registration
              new Proc().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
         public void process(APDU apdu) {
              // Good practice: Return 9000 on SELECT
              if (selectingApplet()) {
                   return;
              byte[] buf = apdu.getBuffer();
              switch (buf[ISO7816.OFFSET_INS]) {
                   case (byte) 0xb1 :
                        break;
                   default :
                        // good practice: If you don't know the INStruction, say so:
                        ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
    client package : (1 class)
    package client;
    import javacard.framework.*;
    public class client extends javacard.framework.Applet{
         private byte[] servAID = {(byte)'A',(byte)'0',(byte)'1',(byte)'0',(byte)'1',(byte)'0',(byte)'1',(byte)'0',(byte)'0',(byte)'0',(byte)'0',(byte)'2'};
         public client()
         private void Call()
         AID settingsAID = JCSystem.lookupAID(servAID,(short) 0, (byte) servAID.length);
            //PROBLEM = BELOW IS THE LINE WHERE I CANT CALL THE SERVER'S PACKAGE "settings"     
           settings sio = (settings)(JCSystem.getAppletShareableInterfaceObject(settingsAID, (byte) 0));
         public static void install(byte[] bArray, short bOffset, byte bLength){
              (new client()).register(bArray, (short)(bOffset + 1), bArray[bOffset]);
         public void process(APDU apdu){
              byte[] buf = apdu.getBuffer();
              switch(buf[ISO7816.OFFSET_INS]){
                   case (byte)0xb1:
                        break;
                   default:
    }

  • Function call in procedure within Package Body

    I am a novice in PL/SQL so that I can't find out where the problem is. I am testing a function call in procedure within a Package Body.
    But the PL/SQL Complier doesn't compile the package body but I don't know what I do wrong. Plz let me know how to call a function in procedure within a Package Body?
    Here are the Packaget test programs..
    CREATE OR REPLACE PACKAGE manage_students
    IS
    PROCEDURE find_sname;
    PROCEDURE find_test;
    PROCEDURE find_test_called;
    FUNCTION GET_LASTMT
    RETURN SEQUENCE_TEST.SEQ_NO%TYPE;
    END manage_students;
    CREATE OR REPLACE PACKAGE BODY manage_students AS
    v_max_nbr SEQUENCE_TEST.SEQ_NO%TYPE;
    PROCEDURE find_sname
    IS
    BEGIN
    BEGIN
    SELECT MAX(SEQ_NO)
    INTO v_max_nbr
    from SEQUENCE_TEST;
    DBMS_OUTPUT.PUT_LINE('MAX NUMBER is : '||v_max_nbr);
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    RETURN;
    END;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    END find_sname;
    PROCEDURE find_test
    IS
    BEGIN
    BEGIN
    DBMS_OUTPUT.PUT_LINE('MAX NUMBER Called from another procedure : '||v_max_nbr);
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    RETURN;
    END;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    END find_test;
    FUNCTION GET_LASTMT
    RETURN SEQUENCE_TEST.SEQ_NO%TYPE
    IS
    v_max_nbr SEQUENCE_TEST.SEQ_NO%TYPE;
    BEGIN
    SELECT MAX(SEQ_NO)
    INTO v_max_nbr
    from SEQUENCE_TEST;
    RETURN v_max_nbr;
    EXCEPTION
    WHEN OTHERS
    THEN
    DECLARE
    v_sqlerrm VARCHAR2(250) :=
    SUBSTR(SQLERRM,1,250);
    BEGIN
    RAISE_APPLICATION_ERROR(-20003,
    'Error in instructor_id: '||v_sqlerrm);
    END;
    END GET_LASTMT;
    PROCEDURE find_test_called
    IS
    BEGIN
    BEGIN
    V_max := Manage_students.GET_LASTMT;
    DBMS_OUTPUT.PUT_LINE('MAX_NUMBER :'|| V_max);
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    RETURN NULL;
    END;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    END find_test_called;
    END manage_students;
    DECLARE
    v_max SEQUENCE_TEST.SEQ_NO%TYPE;
    BEGIN
    manage_students.find_sname;
    DBMS_OUTPUT.PUT_LINE ('Student ID: Execute.');
    manage_students.find_test;
    manage_students.find_test_called;
    END;
    -----------------------------------------------------------------------------------------------

    Hi,
    Welcome to the forum!
    You'll find that there are a lot of people willing to help you.
    Are you willing to help them? Whenever you have a problem, post enough for people to re-create the problem themselves. That includes CREATE TABLE and INSERT statements for all the tables you use.
    Error messages are very helpful. Post the complete error message you're getting, including line number. (It looks like your EXCEPTION sections aren't doing much, except hiding the real errors. That's a bad programming practice, but probably not causing your present problem - just a future one.)
    Never post unformatted code. Indent the code to show the extent of each procedure, and the blocks within each one.
    When posting formatted text on this site, type these 6 characters:
    \(all small letters, inside curly brackets) before and after each section of formatted test, to preserve the spacing.
    For example, the procedure find_test_called would be a lot easier to read like this:PROCEDURE find_test_called
    IS
    BEGIN
         BEGIN
              V_max := Manage_students.GET_LASTMT;
              DBMS_OUTPUT.PUT_LINE ('MAX_NUMBER :' || V_max);
         EXCEPTION
              WHEN OTHERS
              THEN
                   DBMS_OUTPUT.PUT_LINE ('Error in finding student_id: ');
                   RETURN      NULL;
         END;
         COMMIT;
    EXCEPTION
         WHEN OTHERS
         THEN
              DBMS_OUTPUT.PUT_LINE ('Error in finding student_id: ');
    END find_test_called;
    It's much easier to tell from the code above that you're trying to return NULL from a procedure.  Only functions can return anything (counting NULL); procedures can have RETURN statements, but that single word"RETURN;" is the entire statement.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Calling a function in apex region

    Hi
    I want to call a function from a package into Apex report region , but it wont the parse
    i tested in sql dev successfully
    sample code goes like this ..
    SELECT DISTINCT SOR_OFFENDER.FIRST_NAME ||' ' ||
    SOR_OFFENDER.MIDDLE_NAME || ' ' ||
    SOR_OFFENDER.LAST_NAME as "Name",
    SOR_OFFENDER_DETAILS.get_offlu_url(:p216_detail) ---package where function is define
    FROM SOR_OFFENDER,
    SOR_LOCATION
    WHERE SOR_OFFENDER.OFFENDER_ID = SOR_LOCATION.OFFENDER_ID
    AND :p216_detail = SOR_LOCATION.OFFENDER_ID
    any idea /help
    Edited by: Red_Bull on Aug 8, 2012 3:02 PM

    Tony
    I have to use this function to link other page or portal , using different parameter on different reports.
    CREATE OR REPLACE FUNCTION
    get_offlu_url (p_offender_id IN NUMBER) return VARCHAR2
         as
        temp_url_string varchar2(300);
        final_url_string varchar2(300);
        v_doc_num off_profile.doc_num%type;
        v_booking_id off_profile.offender_book_id%type;
        begin
           select http||server||port||dad||start_page into temp_url_string
            from offlu_url;
           select doc_num, offender_book_id into v_doc_num, v_booking_id
             from off_profile
             where offender_id = p_offender_id;
           final_url_string := temp_url_string||'doc_num='||v_doc_num||'&abc='||v_booking_id;
           return final_url_string;
        exception
           when too_many_rows then
               v_doc_num := 0;
               v_booking_id := 0;
        END get_offlu_url;

  • Invoke a function in a package

    I need to call a function in a package that will return back to
    me the database I am connected to
    The package and function is called :p_common.sf_get_dbname
    CallableStatement getDBName=null;
    ResultSet rs2=null;
             try
                  ggetDBName = con.prepareCall("{call ? := P_COMMON.SF_GET_DBNAME()}");
                   getDBName.registerOutParameter(1, OracleTypes.CURSOR);
                   getDBName.execute();
                   rs2 = (ResultSet) getPxCcy.getObject(1);
                   String db =  rs2.getString(1);
                   logger.info("DB connected to is " + db);
    I am not getting the correct dbname? is the above way to do the correct way?

    i need to get the name of the database i am connected to by calling a function in a package
    Connection con = null;
              CallableStatement getDBName = null;
              ResultSet rs2 = null;
              try
                   Object object = Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
                   java.sql.Driver driver = (Driver) object;
                   DriverManager.registerDriver(driver);
                   con = DriverManager.getConnection(dbURL, dbUID, dbPWD);
                   getDBName = con.prepareCall("{call ? := P_COMMON.SF_GET_DBNAME()}");
                   getDBName.registerOutParameter(1, OracleTypes.CURSOR);
                   getDBName.execute();
                   rs2 = (ResultSet) getDBName.getObject(1);
                   while(rs2.next()){
                         String name=rs2.getString(1);
                         logger.info("DB NAME is " + name);
    ERROR:
    java.lang.NullPointerException
    java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00382: expression is of wrong type
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignoredCan anyone please help me on this

  • Call function in the package ....

    I have interesting problem. It's interesting because it works on one server and does not work on another, both servers are ORACLE 10.2.0.2 on Solaris 10, both have identical users.
    when I call pkg_utilities_public.GET_CURRENT_POST_DATE (sysdate) I get correct result on one server and error ORA-00904: "PKG_UTILITIES_PUBLIC"."GET_DATE": invalid identifier on the other, I have a user with DBA rights ...
    what's even more interesting that I can compile this on both servers with no issue
    the issues is how I call GET_DATE, I call it as GET_DATE instead of PKG_UTILITIES_PUBLIC.GET_DATE (lazy way but still should work on both) any idea why this works on one server and not the other? If I call it with PKG_UTILITIES_PUBLIC.GET_DATE it works on both, so I have solution, but I'm wondering why the first thing does not work.
    CREATE OR REPLACE PACKAGE FDM.PKG_UTILITIES_PUBLIC AUTHID CURRENT_USER IS
    --- GETS DATE BASED ON PERIOD_KEY (return YYYYMMDD or YYYYMM)
    FUNCTION GET_DATE (v_period_key number:= 0) RETURN NUMBER ;
    --- if today is post_dt get today, if not get previous post date
    FUNCTION GET_CURRENT_POST_DATE(v_date DATE) RETURN DATE;
    END;
    CREATE OR REPLACE PACKAGE BODY FDM.PKG_UTILITIES_PUBLIC IS
    --- GETS DATE BASED ON PERIOD_KEY (return YYYYMMDD or YYYYMM)
    FUNCTION GET_DATE (v_period_key number:= 0) RETURN NUMBER is
    v_date number;
    BEGIN
    SELECT DECODE(PERIOD_TYPE_CD,'D',TO_CHAR(PERIOD_DT,'YYYYMMDD'),'M',MONTH_OF_YEAR_CD, 0)
    INTO v_date
    FROM FDM.PERIOD
    WHERE PERIOD_KEY = v_period_key;
    RETURN v_date;
    end GET_DATE;
    --- if today is post_dt get today, if not get previous post date
    FUNCTION GET_CURRENT_POST_DATE(v_date DATE) RETURN DATE IS
    v_output_dt DATE;
    BEGIN
    SELECT TO_DATE(GET_DATE(DECODE( POST_DT_FLG,'Y',PERIOD_KEY,'N', PRIOR_POST_DT_KEY)),'YYYYMMDD')
    INTO v_output_dt
    FROM FDM.PERIOD
    WHERE PERIOD_TYPE_CD = 'D'
    AND PERIOD_DT = TRIM(v_date);
    RETURN v_output_dt;
    END;
    Message was edited by:
    jiri
    Message was edited by:
    jiri

    speaking technical and not personal, I think this is related to serilization of SQL engine from PLSQL engine,
    both samples below work on SERVER A,
    sanple 1 does not work on server B, sample 2 works on server B (you can see I removed the call from SQL into PLSQL (this is generally better approach).
    FUNCTION GET_CURRENT_POST_DATE(v_date DATE) RETURN DATE IS
    v_output_dt DATE;
    BEGIN
    SELECT TO_DATE(GET_DATE(DECODE( POST_DT_FLG,'Y',PERIOD_KEY,'N', PRIOR_POST_DT_KEY)),'YYYYMMDD')
    INTO v_output_dt
    FROM FDM.PERIOD
    WHERE PERIOD_TYPE_CD = 'D'
    AND PERIOD_DT = TRIM(v_date);
    RETURN v_output_dt;
    END;
    FUNCTION GET_CURRENT_POST_DATE(v_date DATE) RETURN DATE IS
    v_output_dt DATE;
    v_my_date NUMBER;
    BEGIN
    SELECT DECODE( POST_DT_FLG,'Y',PERIOD_KEY,'N', PRIOR_POST_DT_KEY)
    INTO v_my_date
    FROM FDM.PERIOD
    WHERE PERIOD_TYPE_CD = 'D'
    AND PERIOD_DT = TRIM(v_date);
    v_output_dt := TO_DATE(GET_DATE(v_my_date ),'YYYYMMDD');
    RETURN v_output_dt;
    END;

  • Call outside function with same name in a package

    I created a function as follows:
    create or replace function f1 return number
    is
    begin
    return 1;
    end;
    This f1 is to be called in a package created below.
    Then I create a package with a function in it, as follows:
    create or replace package pack1 as
    function f1 return number;
    end;
    Now I define the package body as follows:
    create or replace package body pack1 as
    function f1 return number as
    -- I am trying to call the first function f1 defined above here
    How do I resolve the name issues here?
    In other words, I want to call a function with the same signature outside a package.
    Thanks for your kind help.

    Hi,
    Welcome to the forum!
    Do you have a good reason for using the same name?
    Refer to the stand-alone function with the owner name, even though it's your current schema.
    That is, even if the package and the stand-alone function are owned by scott, in the package, say
    x := scott.f1;

Maybe you are looking for

  • 'Disable or enable software Secure Attention Sequence' GPO setting | Security Risk

    Hello, In implementing SCCM we discovered that the 'ctrl+alt+del' button for the SCCM Remote Control client, will not work, unless we enable the 'enable software Secure Attention Sequence' GPO setting with 'Services and Ease of Access Applications' s

  • Safari wont load or itunes store or ping

    Hi, i have a windows 7 pc 64bit. Itunes store, safari and ping will not load. This also occurs on a windows 7 32bit pc on the same network. I have uninstalled/reinstalled all apple products. I definitly have the 64bit version of software on the 64bit

  • Adapter Metadata problem

    Hi guys, I have transported a scenario from XI 3.0 to PI 7.1 and, now, when i try to activate my comunicatio channels (in 7.1) I get the following error: "Exception: Attempt to read object Adapter Metadata File...from application REPOSITORY on system

  • Scan a file for virus before upload

    In many CRM functions, eg - Activities, Mkt Planner, etc., there is a tab for uploading/attaching files.  How can we scan the file for virus before saving?  We have a Basis 620, so we can't use the Virus Scan Interface because it is available from Ba

  • No such domain/application: "orabpel"

    Hello, I am using a web application to call a bpel process, but when the application tries to do the lookup it launches this exception: Caused by: java.lang.Exception: Fallo al crear el bean "ejb/collaxa/system/DeliveryBean"; la excepción mostrada es