Can't call a function inside another function

Hello,
i have the following function :
FUNCTION test_day_week (P_DATE DATE)
RETURN VARCHAR2 IS
BEGIN
RETURN TO_CHAR(P_DATE ,'DAY');
END;
--it returns the day name of a given date
FUNCTION TEST_DAY_NUMBER (P_DAY_NAME VARCHAR2)
RETURN NUMBER IS
     V_RESULT NUMBER;
     V_RETURN_DAY VARCHAR2(30);
     P_DATE DATE;
BEGIN
V_RETURN_DAY := test_day_week (P_DATE );
MESSAGE('V_RETURN_DAY'|| V_RETURN_DAY);
MESSAGE('V_RETURN_DAY'|| V_RETURN_DAY);
IF V_RETURN_DAY = 'MONDAY' THEN V_RESULT :=1;
     END IF ;
IF V_RETURN_DAY = 'TUSEDAY' THEN V_RESULT :=2;
     END IF ;
IF V_RETURN_DAY = 'WENDSDAY' THEN V_RESULT :=3;
     END IF ;
IF V_RETURN_DAY = 'THURSDAY' THEN V_RESULT :=4;
     END IF ;
IF V_RETURN_DAY = 'FRIDAY' THEN V_RESULT :=5;
     END IF ;                
IF V_RETURN_DAY = 'SATURDAY' THEN V_RESULT :=6;
END IF ;
IF V_RETURN_DAY = 'SUNDAY' THEN V_RESULT :=7;
     END IF ;
RETURN V_RESULT;
END;
--The above function returnds the day name in numbers
The proble is that when i call test_day_week function it returns no value even it is tested separatly and works fine don't know where is my problem :
1-number of argrments in function[b] TEST_DAY_NUMBER
?? and so ..!
Regards,
Abdetu..

You could also cut the whole thing down to a simple function... (assuming you have a need to customise your start of week rather than use built in date functionality)
SQL> ed
Wrote file afiedt.buf
  1  CREATE OR REPLACE FUNCTION test_day_week (P_DATE DATE) RETURN NUMBER IS
  2  BEGIN
  3    RETURN (INSTR('MONTUEWEDTHUFRISATSUN',TO_CHAR(P_DATE,'DY'))+2)/3;
  4* END;
SQL> /
Function created.
SQL> select test_day_week(sysdate) from dual;
TEST_DAY_WEEK(SYSDATE)
                     1
SQL> select test_day_week(sysdate+1) from dual;
TEST_DAY_WEEK(SYSDATE+1)
                       2
SQL> select test_day_week(sysdate+2) from dual;
TEST_DAY_WEEK(SYSDATE+2)
                       3
SQL> select test_day_week(sysdate+3) from dual;
TEST_DAY_WEEK(SYSDATE+3)
                       4
SQL> select test_day_week(sysdate+4) from dual;
TEST_DAY_WEEK(SYSDATE+4)
                       5
SQL> select test_day_week(sysdate+5) from dual;
TEST_DAY_WEEK(SYSDATE+5)
                       6
SQL> select test_day_week(sysdate+6) from dual;
TEST_DAY_WEEK(SYSDATE+6)
                       7
SQL> select test_day_week(sysdate+7) from dual;
TEST_DAY_WEEK(SYSDATE+7)
                       1
SQL>

Similar Messages

  • Can you call a procedure inside another procedure and how many?

    Ok. I have 3 procedures. I would like to call 2 of the from inside one, but I would like them to be in order.
    So,
    procedure1 // this is in db1
         call procedure2
                this collects, and inserts data into table 2 from db1
                this must be run first
         call procedure3
               this update the table1, and table2 from db2, and db3
               this must be run second
         finish procedure1
               this also updates table1 and table2 from db1 and db3
               this must be run third
    procedure1 end;or should I call a function
    procedures 2, and 3 have there own dblinks to other dbs to gather datat, procedure1 is in the same db.
    the procedures dont have to be like above. If you want to run proc3, and call proc1, and proc2 first so be it. Just an example

    create or replace myPackage
    is
    procedure1;
    procedure2;
    procedure3;
    end myPackage;
    create or replace myPackage body
    is
      procedure1 is
      begin
        -- call 2
        procedure2;
        -- call 3
        procedure3;
      end procedure1;
      procedure2 is
      begin
        do_something_here;
      end procedure2;
      procedure3 is
      begin
        do_something_here;
      end procedure3;
    end myPackage;
    /* now run the procedure1 from sql*plus */
    execute myPackage.Procedure1;Message was edited by:
    Sven W. added packaged call

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

  • Can we call a function within a function??????Urgent

    Dear All,
    Like we can call a procedure from another procedure , in the same way can we call a function within a function. Please reply it's urgent.
    Regards

    > Please reply it's urgent.
    My usual soapbox response.
    Saying your posting is urgent is rude and arrogant. Why? Because you are saying that other people who have posted problems here, have less important problems than yours. That despite how complex and critical their problem may be, yours take priority.
    You're also demaning attention and a quick answer from people that provide support here - in their free time... and not getting paid a single cent for their efforts.
    So just how can you demand any urgency to your posting from them?
    Remember that this is a public forum. You cannot demand anything here. This is not Oracle Support. There are no SLA's here. Basic nettiquette applies.

  • Can I call a function from a dll in LabVIEW that returns:double*string and int.?

    I have a function from a dll that return a double* string and an integer. How can I call this function from LabVIEW? There is a possibility to work in LabVIEW with a double* string?

    pcbv wrote:
    > Hello all,<br><br>The header of the function is:
    >
    > "HRESULT WRAPIEnumerateDevices(WRAPI_NDIS_DEVICE **ppDeviceList, long *plItems);"
    >
    > where WRAPI_NDIS_DEVICE have this form:
    >
    > typedef struct WRAPI_NDIS_DEVICE<br>{<br>
    > WCHAR *pDeviceName;<br>
    > WCHAR *pDeviceDescription;<br><br>}
    > WRAPI_NDIS_DEVICE;<br><br>
    >
    > The function is from WRAPI.dll, used for communication with wireless card.
    > For my application I need to call in LabVIEW this function.
    Two difficulties I can see with this.
    First the application seems to allocate the array of references
    internally and return a pointer to that array. In that case there must
    be another function which then deallocates that array again.
    Then you would need to setup the function call to have a pointer to an
    int32 number for the deviceList parameter and another pointer to int32
    one for the plItems parameter.
    Then create another function in your DLL similar to this:
    HRESULT WRAPIEnumExtractDevice(WRAPI_NDIS_DEVICE *lpDeviceList, long i,
    CHAR lpszDeviceName, LONG lenDeviceName,
    CHAR lpszDeviceDesc, LONG lenDeviceDesc)
    if (!lpDeviceList)
    return ERROR_INV_PARAMETER;
    if (lpDeviceList[i].pDeviceName)
    WideCharToMultiByte(CP_ACP, 0,
    pDeviceList[i].pDeviceName, -1,
    lpszDeviceName, lenDeviceName,
    NULL, NULL);
    if (lpDeviceList[i].pDeviceName)
    WideCharToMultiByte(CP_ACP, 0,
    pDeviceList[i].pDeviceDescription, -1,
    lpszDeviceDesc, lenDeviceDesc,
    NULL, NULL);
    return NO_ERROR;
    Pass the int32 you got from the first parameter of the previous call as
    a simple int32 passed by value to this function (and make sure you don't
    call this function with a higher index than (plItems - 1) returned from
    the first function.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Can we call a function module in ADHOC query

    Hi
    Can we call a function module in ADHOC query if yes how.
    Also we ned to know how to call a function module in SAP query.
    An early responce is appreciated.
    Thanks and best regards
    Rajeev

    Okay as far as I understand your aim is:
    To fill a field in the output list with a value that is based on the current line information and calculated by a function module
    So go to SQ02 and create an additional field in the InfoSet.
    You can refer in the coding to the technical names you can see in the left tree window like P0000-PERNR.
    More information is avaiable in the Help part look for additional field in SQ02.
    Regards,
    Michael

  • How can I call a function from a procedure

    I have a function named: f_calc_value which return the variable v_result. This function is part of a package.
    How can I call this function from a new procedure I am creating?
    Thanks

    or refer this theread....calling function from procedure

  • Can you call a function module from within a smartform?

    I was told that yu can not call a function module from a smartform - that does not make sense to me because you can do tons of ABAP within a smartform.
    Well - can you?
    Thanks.
    Scott

    Yes, you can call function modules.

  • Can i call a function module of SAP?

    Hi, i have a question... Can i call a function module of SAP... I need print a document from a device, can i call the function module of SAP in order that me it prints it?
    Thanks,

    Hi Victor,
    you can use the GenericSync Example of the MDK. This calls the Module to verify the user directly. Generic Sync is exactly for that purpose: call a BADI directly and no usage of SyncBO. Be aware, that you - out of the box- sync your app data as well at that moment, because a sync runs both - generic and smartsync. Even worse: even when you have nothing to sync in Generic Sync - so nothing to print - it will call the function module for generic sync as long as it is registered.
    Well,  anyway, this is the way to call a function module separate.
    If it works with you rparticular print module? I have no idea, but if this is a normal function module - well, it should be ok.
    Hope this helps.
    Regards,
    Oliver

  • Can one call a function module in Calculated Key Figure?

    Can one call a function module in Calculated Key Figure? If  yes how, if not, what is the solution if formula does not suffice?
    I want to convert duration which is in seconds to   Duration in Hours and Minutes. There is a function module for doing it. Not sure how to do it in a formula.

    One option you have is a Virtual Key Figure and User Exit to use the Function Module to convert the time from seconds to HH:MM. Here are two documents on this subject to help you create them, based on the technology your comfortable with:
    [Implementing Virtual Key Figure/ Characteristics Makes Query More Dynamic|https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/e051fda8-71a9-2a10-ac9e-8d17414a8c8c&overridelayout=true]
    [Step By Step Process for Virtual Key Figures and Characteristics through BAdi|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/60e34f63-f44c-2c10-488e-c89b04e0ca7c&overridelayout=true]

  • Can we call a Function Module with in a loop

    Hi,
    Can we call a Function Module within a loop . Does it reduces the performance.
    Can you please guide regarding this.
    With Best Regards
    Mamatha.

    hi Mamatha,
      You can call .. but it is better to avoid calling it within a loop...
    Loop at it_tab.
       call function 'CONVERSION_EXIT_ALPHA_INPUT'
        exporting
          input  = it_tab-vbeln.
        importing
          output = it_tab-vbeln.
    endloop.
    Regards,
    Santosh
    Message was edited by:
            Santosh Kumar Patha

  • Can we call custom functions in view objects?

    Can we call custom functions in view objects?these custom functions are from my backing bean...
    Please help.....

    User,
    You can certainly add code to your view objects to do whatever you like.
    However, it would be considered a very bad practice to call something in the backing bean from your view object. It violates the whole MVC design principle of ADF.
    Perhaps if you can share your real use case, someone will give you ideas about the best way to do it, but I, for one, would advise you to forget about calling a backing bean function from your view object.
    Best,
    John

  • Can LabVIEW call a function from a .sys file or is LabVIEW limited to dll access?

    My vendor has sent me a .sys file with functions accessing their hardware.  Can i call these function from labview directly or do I have to wrapper the .sys with a dll?

    Well a sys file is a kernel device driver. LabVIEW does not have any direct way of accessing such a driver. The way kernel drivers are accessed is usually through a DLL which makes calls to WinAPI functions such as CreateFile(), ReadFile(), WriteFile(), CloseHandle() and DeviceIORequest(). Since these WinAPI calls are basically just DLL calls too, you could theoretically use the Call Library Node to call them and access the kernel device driver in such a way.
    However for any kernel device driver with more than one or two device driver calls, it will certainly be easier in terms of development, debugging and maintenance of the code, to write actually a dedicated DLL in C/C++ for this device driver and access that DLL from LabVIEW, especially if you consider the LabVIEW datatype limitations when designing the DLL interface (Basically this same DLL can then be called from any other Windows development environment, be it Visual Basic (similar datatype limitation as LabVIEW), Delphi, (Visual) C, LabVIEW or also various scripting environments like Python and Lua.
    Some of the necessary WindAPI calls are rather involved and pose quite a bit of trouble to get the parameter data right in LabVIEw.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Can we call a report in another report?

    I have developed a XMLP report for AR receivables for a customer and another XMLP report for AP vouchers for a customer.
    Now my requirement is to develop a report for AR/AP Balance for a customer,which is combination of above 2(ie AR Receivables report + AP vouchers report).
    What is the possible solution to above mentioned requirement??
    Can I call a report from another report(for ex AP vouchers report from AR Receivables report).Is this possible?
    If yes,please explain...
    Or are there any alternatives to this requirement??
    Thanks in advance!!

    Hi,
    Calling another report in a report? Not sure about your requirement but you can do fnd_submit/fnd_request.
    OR, if you need AR/AP balance,... here's an alternative solution:
    If you're in R12, there is the "Automatic Netting (AP/AR)" feature in Payables. You could check on the available report if it fits your need.
    In 11i, you may run "Supplier Customer Netting Report" (ARXSCN). This is an OReport(RDF) and could be converted to XMLP. This report is designed to display the net balances in AP and AR for Vendors and Customers with the same name, NIF Code, or VAT Registration.
    Hope this helps.
    Rownald

  • Can we call main method in another class?

    Hi...
    can we call main method in another class?
    If no, please tell me the exact reason why can't we call that....

    ok
    can u give that code for me?
    class A {
    public static void main(String [] args){
    System.out.println("In A");
    class B {
    public static void main(String [] args){
    A.main(null);
    }

Maybe you are looking for

  • How do i get all the content of my iPod on a new itunes.

    My old computer died on me and i bought a new laptop. I downloaded the newest iTunes (10.1.1) on it, so now i have a new iTunes and it's not accepting my iPod. I don't want to synchronise my iPod to the new iTunes for in that case i will loose everyt

  • To get content of file upload element in web dynpro

    Hi . . . h1 : how can i get the string content   (i.e., path of file) store in variable in web dynpro abap . . . .

  • What is the importance of "AdobePatchFiles" in my iMac?

    In my Apple iMac under Applications>Adobe I find the folder AdobePatchFiles with hundreds of files in it. A limited number are "documents" the remainder are "Unix Excutable files" They are all modified on the same date 28 november 2011. What is the m

  • CUP 5.3. Request administration

    Hi together, How is it possible to have a look at all requests which are edited by the admin? Our revisors want to see all requests, where the admin has to react. Is it only possible to get this information about reports etc? Thanks. Alexa

  • Add-on 9000034 failed with exception; in blocking expire date batch in GR

    Hi all , I try to set mandotory in expire date field in batch setup of good receipt. My code is like this If (pVal.FormTypeEx = "41") Then             oForm = SBO_Application.Forms.Item(FormUID)             If (pVal.Before_Action = True) Then