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;

Similar Messages

  • Suppose in a Package Spec there are 3 functions and Package Body there are 5 functions will the package compile?

    Suppose in a Package Spec there are 3 functions and Package Body there are 5 functions will the package compile?

    Rather than asking these basic one-liner questions (When a package is created how many database objects are created?) why don't you explain what issues you are experiencing after you've read the documentation and tried things yourself.
    The forums are for people to help when they experience issues, not when they can't be bothered to read the documentation or searcht the web for the basic information that's already explained.
    Re: 2. How do I ask a question on the forums?
    Re: 1. Where can I find Oracle Documentation?

  • How to call functions that return package local types?

    Hi everyone, I have a Pl/Sql function in a package that returns a package-local type.
    I would like to call this function from Java, but I don't know what to pass to "statement.registerOutParameter()"
    (it gives this error:
    Unable to resolve type: "XDRIVE_B2B.TEST1.MYTYPE)
    Here's the simple version with one package:
    package TESTPKG IS
    TYPE MYTYPE IS VARRAY(1) OF INTEGER;
    FUNCTION FCT2 RETURN MYTYPE;
    end;
    package body testpkg IS
    FUNCTION FCT2 RETURN MYTYPE IS
    BEGIN
    RETURN mytype(55);
    END;
    end;
    and here's the java code:
    void javatest(OracleConnection conn)
    throws SQLException
    String sql = "{ call ? = testpkg.fct2() }";
    OracleCallableStatement st =
    (OracleCallableStatement) conn.prepareCall(sql);
    st.registerOutParameter(1, OracleTypes.ARRAY, "MYUSERNAME.TESTPKG.MYTYPE");
    st.execute();
    and as I said above, the java code fails with:
    java.sql.SQLException: Fail to construct descriptor: Unable to resolve type: "MYUSERNAME.TEST1.MYTYPE"
    I can't really have this type live outside of a package because in the real case, it's not a VARRAY(1) of integer, it's a VARRAY(1) of MYTABLE%ROWTYPE, which only seems to compile inside a package.
    thanks for any opinions,
    george moudry
    null

    JDBC, JPublisher, and SQLJ do not support PL/SQL-only types. This includes PL/SQL index tables and record types.

  • Calling functions of the inner class in .java code file

    Hello,
    I created a .java code file in Visual J#.Net and converted it into
    the application by adding the "public static void main(String args[])"
    function.
    I have created the two classes one extends from Applet, and the other
    extends from Frame. The class which I inherited from the Frame class becomes
    the inner class of the class extended from the Applet. Now How do I
    call the functions of the class extended from Frame class - MenuBarFrame
    class. the outline code is
    public class menu_show extends Applet
    ------init , paint action function---------
    public class MenuBarFrame extends Frame
    paint,action function for Menu
    public static void main(String args[])
    applet class instance is created
    instance of frame is created
    Menu , MenuBar, MenuItem instance is created
    and all these objects added
    I have Created MenuBarFrame class instance as
    Object x= new menu_show().new MenuBarFrame
    ????? How to call the functions such as action of MenuBarFrame class - what
    should be its parameters??????
    }

    Here's how I would do it:
    interface Operation {
        public int op(int y);
    class X {
        private int x;
        public X(int x) {
            this.x = x;
        private class Y implements Operation {
            public int op(int y) {
                return x+y;
        public Operation createOperation() {
            return new Y();
        public static void main(String[] args) {
            X app = new X(17);
            Operation f = app.createOperation();
            System.out.println(f.op(-11));
    }Your code, however, has some serious "issues". You typically don't
    instantiate an applet class -- that's the job of the applet viewer or Java plugin
    your browser is using. If you instantiate the applet directly, you're going
    to have to supply it an AppletStub. Do you really want to go that way?
    Again, use an applet viewer or browser, or better yet, why write applets at all?

  • Call Function from SSIS package

    Hello.  I have a field pulled from an Access database that I need to manipulate before processing.  I need to strip out illegal characters.  What's the best way to use a function to process the data in the table.  I was hoping to do this
    within the package if possible.  
    From within Access, a query passed values to a function defined within a code module and returned the new value.  The SSIS package needs to be able to do this as well.

    Hi,
    You can can remove the illegal characters in the package. On your Data Flow Task drag a script component in the script component input columns only check the field you will process.
    private string NewCharacter(string character)
    string replacestr= System.Text.RegularExpressions.Regex.Replace(character, "[^a-zA-Z0-9.]+", " ");
    return replacestr.Trim();
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    if(Row.FieldName_IsNull == false)
    {//Assign the new value
    Row.FieldName = NewCharacter(Row.FieldName);

  • Calling function on the basis of parameter passing in oracle discoverer

    Hi,
    In my report i want to pass parameter for currency and want to call a function. Is it possible in oracle discoverer to call function created in oracle database.

    Hi Rod,
    e.g i have report. While i run the report parameter wizard dialog box open. i have different parameter like Module, Country, Date etc right now, not using currency.
    The report shows me the following fields
    Actual Sales, last yr Sales, Target
    1000 5666 100000
    etc. And all Dara in Currency SAR by default.
    Now,
    There is one another parameter i.e. Currency and i entered the value for currency as INR. and also enter the other parameters
    I want that as this currency INR enter,it call that currency conversion function and convert the data in INR.
    and when i click the OK button in Parameter wizard I want to see the same data in INR currency.
    If the above is possible then please tell my by steps.
    if you can share your email id so that i can show you the report, and clear my requirement.
    Thanks
    kam

  • Calling functions in a package from jdbc

    I am trying to call a function in a PL/SQL package from a java program using JDBC. Is this a valid option? The statement I am using is the following:
    stProc = myconnect.prepareCall ("{? = call process_monitor_pkg.open_sod_cursor}");
    I am receiving the following error message:
    Errorjava.sql.SQLException: ORA-06576: not a function or procedure
    I have verified that the function/package is defined and that I have the correct output parameter registered.
    Any help would be greatly appreciated.

    try this :
    stProc = myconnect.prepareCall (
    "{ ? = call process_monitor_pkg.open_sod_cursor() }");
    You have to put parenthesis even if there's no parameters...

  • How to call function behind the button and update only specific record

    Greetings,
    1 - i wnat to ask few things as i m new to apex, i am using apex 4.1, and created 3 select list and a button in seleting of parameter,
    1 select list : select area
    2 select list: select product
    3- select list - size of the product
    i want to generate Ids for the follwing. for that i created query for INSERTING RECORD FROM ONE TABLE TO ANOTHER , generation the ids when button pressed "Generate" after selecting parameters,
    Now where i call that QUERY on button ? because when i create button its gives me option to submit, defined dynamic action, etc, pls gudie me where i call the function name id_generation when button pressed?.
    2- second thing i creared tabular " select user_id, product_name, product_type from product".
    by defualt check box list are create delete submit button are created, first when i insert record it saves that was fine, e.g i entered 50 records and afterward i want to update only one record, e.g there is a record product name = box, if i change it to box small and click submit then it saves all the page means all 50 records,
    i want to submit only that record that i changed, for that i use the logic that only those records should be updated which are checked but the user. how will i do this ? where to use the preocess , please guide
    Edited by: Omzz on Oct 2, 2012 11:28 PM

    If I understand what you are trying to do is correct you could possibly do this by:
    Creating and AFTER INSERT trigger on the table based on the tabular form which inserts the record into a seperate table after the record is inserted something like:
    CREATE OR REPLACE TRIGGER copy_records
    AFTER INSERT ON table a
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    BEGIN
    INSERT INTO table b
    VALUES :NEW.col1, :NEW.col2 etc......
    END;
    There is also a way that you could do it within the form using a cursor on the tabular form with APEX_APPLICATION.G_ ......
    Chris

  • Calling functions in the order I want?

    In a Layer I have 2 functions, function1() and function2().
    I am trying to call these function from an another Layer, in
    following order:
    function1();
    function2();
    But no matter what I do, Actionscript choose to call
    function2() before function1(). I find this very strange.
    Something is wrong. Do you know what?
    Thank you all for your help!

    Well, the evidence is pretty simple.
    In Layer A I write:
    function myFunction1(){
    trace(“test1”);
    function myFunction2(){
    trace(“test2”);
    In Layer B I call these functions
    _root.myFunction1();
    _root.myFunction2();
    I should expect:
    test1
    test2
    No matter what I do, "test2" appears before "test1".
    When you are testing this, make sure that you are calling the
    functions from different Layer. Read the link myIP has posted!

  • Using todays date as default for this function in the package

    Dear all;
    please find attached the following sample data and syntax
    create table tbl_one
      id varchar2(200),
      place varchar2(300),
      create_date date
    insert into tbl_one
      (id, place, create_date)
    values
      ('D', 'MN', to_date('3/3/2011', 'MM/DD/YYYY'));
    insert into tbl_one
      (id, place, create_date)
    values
      ('X', 'DC', to_date('3/4/2011', 'MM/DD/YYYY'));
    insert into tbl_one
      (id, place, create_date)
    values
      ('A', 'NY', to_date('3/31/2011', 'MM/DD/YYYY'));package from PL/SQL developer
    body ----------
    create or replace package P_test is
      -- Public type declarations
    type cur is ref cursor;
    function test_fn
    from_period in varchar2,
    to_period in varchar2
    ) return cur;
    end P_test;
    spec ----------------------
    create or replace package body P_test is
    function test_fn
    from_period in varchar2,
    to_period in varchar2
    ) return cur as
    my_cur cur;
    Begin
      open my_cur for
      select p.id,
             p.place
      from tbl_one p
      where trunc(p.create_date) >= to_date(from_period, 'MM-DD-YYYY')
      and trunc(p.create_date) <= to_date(to_period, 'MM-DD-YYYY');
    return my_cur;
    end test_fn;
    end P_test;now I was just wondering how do I get the to_period to have a default value of todays date

    user13328581 wrote:
    I tried that already but it doesnt work unfortunately it shows no display...the only other way i can think of is use several if statement to check and then do a select into....however i just feel there is a better way to do it.
    Edited by: user13328581 on Mar 31, 2011 1:09 PMDefine it doesn't work.
    SQL> CREATE PROCEDURE dt_test (p_start_dt IN VARCHAR2,
      2                            p_end_dt   IN VARCHAR2 DEFAULT TO_CHAR(sysdate, 'MM-DD-YYYY')) AS
      3  BEGIN
      4     DBMS_OUTPUT.Put_Line ('Start is: '||p_start_dt);
      5     DBMS_OUTPUT.Put_Line ('End is: '||p_end_dt);
      6  END;
      7  /
    Procedure created.
    SQL> exec dt_test('01-01-2011', '02-28-2011');
    Start is: 01-01-2011
    End is: 02-28-2011
    PL/SQL procedure successfully completed.
    SQL> exec dt_test('01-01-2011');
    Start is: 01-01-2011
    End is: 03-31-2011Or are you always passing two parameters with the end date possibly null like this:
    SQL> exec dt_test('01-01-2011', null);
    Start is: 01-01-2011
    End is:
    PL/SQL procedure successfully completed.If that is you case then you can do something like:
    SQL> CREATE OR REPLACE PROCEDURE dt_test (p_start_dt IN VARCHAR2,
      2                                       p_end_dt   IN VARCHAR2) AS
      3  BEGIN
      4     DBMS_OUTPUT.Put_Line ('Start is: '||p_start_dt);
      5     DBMS_OUTPUT.Put_Line ('End is: '||COALESCE(p_end_dt, sysdate));
      6  END;
      7  /
    Procedure created.
    SQL> exec dt_test('01-01-2011', null)
    Start is: 01-01-2011
    End is: 31-MAR-2011
    PL/SQL procedure successfully completed.So your predicate would become more like:
    trunc(p.create_date) <= COALESCE(to_date(to_period, 'MM-DD-YYYY'), TRUNC(sysdate);John

  • How to call function in the plugin from javascript?

    Hi,
    I have some function inside my plugin which i want to call from javascript. Is it possible? Sorry, im new to plugin programming.
    For example, i have plugin with function func() which i want to call from external javascript. In what way i will be able to achieve this?
    Thanks.

    Thank you sir for the help.
    Is it possible to assign ID to function and specifying that ID during executeAction call in script?
    Like at the time of executeaction call we will specify pluginID and functionID as parameter so that function will execute from the respective plugin. Is it possible ?
    Thanks.

  • What is the difference between the function declared in the package and pac

    What is the difference between defining a function in the package and package body ?
    Edited by: user10641405 on Nov 19, 2009 1:29 PM

    If you describe a package, you will only see the functions declared in the spec.
    If you only declare them in the body then they are not available to other packages (they are private to the package, not public)

  • Function scope in Package  PLS-00231:

    In my package body, one local function_A is calling local function_B. Since both functions will not be called outside of the package (function_A will be called by a public procedure, which is defined in the package spec), I did not want to define A and B in my Package spec. However, when I compile the body, I get the following error message:
    Error(46,30): PLS-00231: function 'FUNCTION_B' may not be used in SQL
    If I add function_B to my package spec (even though it is not public), the error message will go away.
    Does anybody knows why?
    Thanks.

    The error message appears to indicate that function_B is being called in a SQL/DML statement:
    select function_B(n) from...
    If this is the case, and is necessary (i.e. it's not a pointless query select function_B(n) from dual) then function_B must be declared publically in the package spec as the SQL engine - and hence any SQL or DML statement - is outside the scope of the package, regardless of whether the only SQL calling it is in the package or not.
    Note that this forum is for discussion of the Oracle SQL Developer development tool. General PL/SQL queries such as this are better dealt with on the PL/SQL.

  • Making a function using the update query - Error message PLS-00103

    I keep getting the following error message in my pl/sql developer everytime, I try creating this function in my package
    PLS3-00103 Encountered the symbol ";" when expecting one of the following return
    Kindly note, what I am trying to do is get a user inputs to perform an update for a specific row in a table called accountingtable which is located in the ccl schema. I dont want to make a return though in my update function.
    Specfication of the package
    FUNCTION update_price(needed_newprice in ccl.accountingtable.price%rowtype,
    partforupdate in ccl.accountingtable.part_id%rowtype,
    colourpart in ccl.accountingtable.colour_id%rowtype);
    body of package
    FUNCTION update_price(needed_newprice in ccl.accountingtable.price%rowtype
    partforupdate in ccl.accountingtable.part_id%rowtype,
    colourpart in ccl.accountingtable.colour_id%rowtype);
    BEGIN
    update accountingtable
    set price = (needed_newprice)
    where part_id = (partforupdate)
    and colour_id = (colourpart );
    END update_price;
    Thanks in advance for any help.

    Hi,
    Never write, let alone post, unformatted code. Indent the code to show the extent of each function, blocks within each function, nested calls, and things like that.
    When posting formatted code on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    Post complete statements that people can run to re-create the problem.
    There should not be a semicolon immediately after the argument list of a function in the package body, but you do need to sepcify what datatype the function will return, and then have the keyword IS (or AS).
    That is, a function starts like this in the package body :FUNCTION fubar
         in_id          IN     INTEGER
    RETURN     VARCHAR2
    IS
    BEGIN
    The same function is declared in the package spec like this:FUNCTION fubar
         in_id          IN     INTEGER
    RETURN     VARCHAR2;

  • What is customer's modification concept in Call function??

    Following is the definition of CALL CUSTOMER-FUNCTION <func>...
    It is similar to CALL FUNCTION. The function modules must be programmed and activated within the <b>customer's modification concept</b>.
    Here,I am not able to understand what is meant by :  CALL CUSTOMER-FUNCTION ??

    It is nothing but one type of Enhancement(user exit) like thing to write out code with respect to that program.
    We use user exits in different ways from CMOD, SMOD etc
    for certain programs, with in the program SAP has provided this type type of CUSTOMER FUNCTION '001'.
    double click on the '001' and create your own include and write the related code in that for your requirement.
    Customer Exit
    SAP creates customer exits for specific programs, screens, and menus within standard applications. These exits do not contain any functionality. Instead, the customer exits act as hooks. You can hang your own add-on functionality onto these hooks.
    If you want to enhance the functionality of your SAP System, you should take advantage of the exits available in standard applications. There are two main reasons why you should use exits rather than modifying SAP software yourself. Add-ons attached to exits have the advantage that:
    • They do not affect standard SAP source code
    When you add new functionality to your SAP System using SAP’s exits, you do not alter the source code of standard SAP programs in any way. The code and screens you create are encapsulated as separate objects. These customer objects are linked to standard applications, but exist separately from SAP’s standard software package.
    • They do not affect software updates
    When you add new functionality to your SAP System using SAP’s exits, your objects (called customer objects) must adhere to strict naming conventions. When it comes time to upgrade a to a new software release, customer objects’ names ensure that they will not be affected by any changes or new additions to the standard software package.
    Customer exits are not available for all programs and screens found in the SAP System. You can only use customer exits if they already exist in the SAP System. You can find more information about locating applications with pre-defined exits in Locating Applications that have Exits
    CALL CUSTOMER-FUNCTION '003'
    exporting
    xvbak = vbak
    xvbuk = vbuk
    xkomk = tkomk
    importing
    lvf_subrc = lvf_subrc
    tables
    xvbfa = xvbfa
    xvbap = xvbap
    xvbup = xvbup.

Maybe you are looking for

  • Can't delete files in iTunes 10.4 (80) OS 10.7 Delete in the edit menu is not hi-lighted?

    Can't delete files in iTunes 10.4 (80) OS 10.7 Delete in the edit menu is not hi-lighted. Any sugestions? I have three Mac's and they all have the same problem.

  • Problem in sap login

    Hi experts,   when i am logging in saplogon error message occurs like <u><b>'no hw id received by messg server'</b></u>. actually yesterday i added one profile in transaction RZ10 and i deleted  that one. i created one profile with some name which i

  • Premiere Pro 1.5 not initializing

    I realize I need to upgrade at some point just can't do it yet. I was directed to the forums here after two chat sessions and a phone call with support. Seems this is the only support for Pro 1.5 Here's my issue. Software purchased in 05 and was an o

  • Where to find companion cd or sample schemas?

    Hi I have Oracle 10g Express Edition intalled on Windows XP. I would like to test the sample schemas but I can only find the Human Resources installed. I read somewhere that they are available on the Oracle 10g companion CD, where can I find this? I

  • How to display dashboard on My Homepage

    How do you display a dashboard on the homepage? I haven't had success trying to create a custom report using the dashboard and my attempt at using a web applet hasn't turned out well either. Thanks in advance!