How to Create a Procedure/Function to Return more than one value

How I can write a function/Procedure to which one value is passed and it will return nine values. How I can use these values

Syed,
I would use PL_SQL table versus a VARRAY for this purpose as you will have an advantage of joining PL_SQL table if you want to in your SQL statements in the procedure.
1. At the SQL prompt, create a type using,
   create or replace type myTable as table of VARCHAR2(100);
2. Pass the table to your procedure as IN OUT parameter,
Create or replace procedure
myProc(pvar1 IN Number, passingArray IN OUT myTable) AS
Begin
    --Fill the array with your logic
    for i in 1..9
    loop
        passingArray.extend;
        passingArray(passingArray.count) := 'what ever';
    end loop; 
End;
3. From your Main prog, you call  Myproc
   --declare a variable for type first
   passingArray myTable := myTable();
   begin
   myProc(10, passingArray());
   --At this point, You would be able to Join the PL_SQL table
   --which gives you the power of using SQL with PL_SQL tables
   end; -- end of main program
4. All done!I have not shown how to use PL_SQL tables in SELECT statements, as that is not the subject here.
At the end of the story, I would say, if you know the number of arguments that you are going to pass to a procedure, Simply use "that many" IN OUT parameters to finish your task(9 in your case). Although the proc call looks large with this, it is much simpler. The above approach is VERY helpful if YOU DO NOT KNOW THE NUMBER OF ARGUMENTS that you are sending AND receiving From a procedure.
Thx,
SriDHAR

Similar Messages

  • Can Function Return more than One Values ??

    Hi Experts,
    I would like to ask you Can Function Return more than one values. I Used Function with Out and In out parameter and its working Fine..
    1. what is harm using Out and In out parameter in function
    2. if we can use Out and In out parameter in Function so what is deffernce between procedure and Function.
    3. Is there any Other Way Though which we can return more the One values in Function.
    Please advice me...
    Thanks
    Umesh Goel

    Yes/No.
    You can return multiple value from function. But, in PL/SQL and not in a SQL.
    The following examples demonstrate that -
    SQL*Plus: Release 9.2.0.1.0 - Production on Wed Mar 28 17:41:15 2007
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> create or replace package glob
      2  as
      3    b varchar2(20);
      4    c varchar2(20);
      5  end;
      6  /
    Package created.
    SQL>
    SQL> create or replace function test_mul_out(a in number)
      2  return number
      3  is
      4    cursor c1(eno in number)
      5    is
      6      select ename,job,sal
      7   from emp
      8   where empno = eno;
      9  
    10    rec c1%rowtype;
    11    d  number(10);
    12  begin
    13    open c1(a);
    14    loop
    15      fetch c1 into rec;
    16      exit when c1%notfound;
    17       glob.b:= rec.ename;
    18    glob.c:= rec.job;
    19    d:= rec.sal;
    20    end loop;
    21    close c1;
    22    return d;
    23  end;
    24  /
    Function created.
    SQL> set serveroutput on
    SQL>
    SQL> declare
      2    zz  number(10);
      3  begin
      4    select test_mul_out(7777)
      5    into zz
      6    from dual;
      7    
      8    dbms_output.put_line('Ename: '||glob.b);
      9    dbms_output.put_line('Job: '||glob.c);
    10    dbms_output.put_line('Sal: '||zz);
    11  end;
    12  /
    Ename: Avik
    Job: CLERK
    Sal: 3456
    PL/SQL procedure successfully completed.
    SQL> Regards.
    Satyaki De.

  • Can oracle  function return more than one value

    Hi All
    please answer can oracle function return more than one value
    need one schenario
    regards

    Can any function, irrespective of the language, return multiple values?
    OF COURSE NOT!!
    So why do you think Oracle will now suddenly do it differently than all other languages? Never mind that it is impossible for a function (a unit/module of code) returning a memory address, to return multiple memory addresses. The machine code that does that, has not been yet been designed/implemented.
    I am continually amazed that this question is asked. It is about something so fundamental in almost every single 3rd and 4th generation language... something that is taught right at the start... the definition of what a procedure and what a function is.
    Sorry, but I simply cannot pull punches on this subject and smooth it over. There is something fundamentally wrong with your training as a programmer if you have to ask such a question about a function.
    And whatever programming skills you build on such a foundation, will be seriously lacking.
    I kindly suggest that you get back to the very basics of programming - and review and revisit until you fully understand it. There are no shortcuts in becomming a good programmer.
    Message was edited by:
    Billy Verreynne

  • How to find out which sub query returns more than one row

    Hi all,
    Can any one give me clue ,how to find out which sub query returns more than one row in the following query .
    /* Formatted on 2011/05/17 19:22 (Formatter Plus v4.8.8) */
    SELECT a.*, ROWNUM AS rnm
      FROM (SELECT DISTINCT '1' AS "Page View", ou.org_unit_name AS "Org",
                            prxm.mbr_idntfr AS "Beneficiary ID",
                               md.last_name
                            || ', '
                            || md.first_name AS "Beneficiary Name",
                            pci.idntfr AS "Tracking No.",
                            TO_CHAR (TRUNC (req.pa_rqst_date),
                                     'MM/dd/yyyy'
                                    ) AS "Request Date",
                            sts.status_name AS "Status",
                            req.pa_rqst_sid AS "Request #",
                            prxm.mbr_sid AS "Mbr_sid",
                            TO_CHAR
                                  (TRUNC (req.pa_revision_date),
                                   'MM/dd/yyyy'
                                  ) AS "Last Updated",
                            TO_CHAR (psd.TO_DATE, 'MM/dd/yyyy') AS "TO_DATE",
                            prxpl.prvdr_lctn_iid AS "PRVDR_LCTN_IID",
                            pd.prvdr_sid AS "PRVDR_SID", 'Y' AS "State View",
                            DECODE
                               ((SELECT DISTINCT pd.national_prvdr_idntfr
                                            FROM pa_request_x_provider_location prxplo
                                           WHERE prxplo.pa_rqst_sid =
                                                                   req.pa_rqst_sid
                                             AND prxplo.oprtnl_flag = 'A'
                                             AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                0, (SELECT prxplo.prvdr_lctn_idntfr
                                      FROM pa_request_x_provider_location prxplo
                                     WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                       AND prxplo.oprtnl_flag = 'A'
                                       AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                NULL, (SELECT prxplo.prvdr_lctn_idntfr
                                         FROM pa_request_x_provider_location prxplo
                                        WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                          AND prxplo.oprtnl_flag = 'A'
                                          AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                (SELECT DISTINCT pd.national_prvdr_idntfr
                                            FROM pa_request_x_provider_location prxplo
                                           WHERE prxplo.pa_rqst_sid =
                                                                   req.pa_rqst_sid
                                             AND prxplo.oprtnl_flag = 'A'
                                             AND prxplo.pa_prvdr_type_lkpcd = 'RR')
                               ) AS "NPI/ID",
                            DECODE
                               ((SELECT pd.org_bsns_name
                                   FROM pa_request_x_provider_location prxplo
                                  WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                    AND prxplo.oprtnl_flag = 'A'
                                    AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                NULL, (SELECT    pd.last_name
                                              || ', '
                                              || pd.first_name
                                              || ' '
                                              || pd.middle_name
                                         FROM pa_request_x_provider_location prxplo
                                        WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                          AND prxplo.oprtnl_flag = 'A'
                                          AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                (SELECT pd.org_bsns_name
                                   FROM pa_request_x_provider_location prxplo
                                  WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                    AND prxplo.oprtnl_flag = 'A'
                                    AND prxplo.pa_prvdr_type_lkpcd = 'RR')
                               ) AS "Prvdr Name",
                            TO_CHAR (psd.from_date,
                                     'MM/dd/yyyy'
                                    ) AS "Srvc From Date",
                            TO_CHAR (req.validity_start_date,
                                     'MM/DD/YYYY'
                                    ) AS "Due Date",
                            (fn_get_busniess_days (TRUNC (req.validity_start_date))
                            ) AS "Days<br>Left",
                            req.pa_mode_type_lkpcd AS "Source",
                            TO_CHAR (TRUNC (wmdtl.rtng_date),
                                     'MM/dd/yyyy'
                                    ) AS "Assigned On",
                            NVL (wmdtl.assigned_to_user_name,
                                 'Not Assigned'
                                ) AS "Assigned To",
                            req.org_unit_sid AS "OrgUnitSid",
                            TO_CHAR
                                 (wmdtl.modified_date,
                                  'MM/dd/yyyy hh24:mi:ss'
                                 ) AS "WTRD_MODIFIED_DATE",
                            TO_CHAR (wmdtl.rtng_date,
                                     'MM/dd/yyyy'
                                    ) AS "WTRD_RTNG_DATE",
                            req.status_cid AS "PA_STATUS_CID",
                            TO_CHAR (req.modified_date,
                                     'MM/dd/yyyy'
                                    ) AS "PA_REQ_MODIFIED_DATE",
                            prs.state_pa_srvc_type_code
                                                     AS "STATE_PA_SRVC_TYPE_CODE",
                            wmdtl.wm_pa_task_rtng_dtl_sid
                                                        AS "WM_TASK_RTNG_DTL_SID",
                            wmdtl.assigned_to_user_acct_sid
                                              AS "WTRD_Assigned_to_user_acct_sid",
                            (fn_get_busniess_days (TRUNC (req.validity_start_date))
                            ) AS "Days<br>LeftSort",
                            wmdtl.assigned_to_org_unit_sid
                                                  AS "WTRD_Assigned_to_OrgUntSid",
                            DECODE
                               ((SELECT COUNT (*)
                                   FROM pa_request_status prs
                                  WHERE prs.pa_rqst_sid = req.pa_rqst_sid
                                    AND prs.status_cid = 5
                                    AND prs.oprtnl_flag = 'I'),
                                0, 'N',
                                'Y'
                               ) AS "SHOW_UTILIZATION"
                       FROM   pa_request req,
                             pa_certification_identifier pci,
                             status sts,
                             pa_request_x_member prxm,
                             wm_pa_task_routing_detail wmdtl,
                             pa_service_date psd,
                             org_unit ou,
                             pa_request_service prs,
                             pa_request_x_provider_location prxpl,
                             provider_location pl,
                             provider_detail pd,
                             provider p,
                             mbr_dmgrphc md
                      WHERE req.oprtnl_flag = 'A'
                        AND req.status_cid NOT IN
                                     (20, 30, 70, 25, 80, 96, 85, 5, 97, 98, 101)
                        AND req.org_unit_sid IN
                               (3057, 3142, 3058, 3143, 3059, 3144, 3060, 3145,
                                3061, 3146, 3062, 3147, 3063, 3148, 3064, 3149,
                                3065, 3150, 3066, 3151, 3067, 3152, 3068, 3153,
                                3069, 3154, 3070, 3155, 3071, 3156, 3072, 3157,
                                3073, 3158, 3074, 3159, 3075, 3160, 3076, 3161,
                                3077, 3162, 3078, 3163, 3079, 3164, 3080, 3165,
                                3081, 3166, 3082, 3167, 3083, 3168, 3084, 3169,
                                3085, 3170, 3086, 3171, 3087, 3172, 3088, 3173,
                                3089, 3174, 3090, 3175, 3091, 3176, 3092, 3177,
                                3093, 3178, 3094, 3179, 3095, 3180, 3096, 3181,
                                3097, 3182, 3098, 3183, 3099, 3184, 3100, 3185,
                                3101, 3186, 3102, 3187, 3103, 3003, 75000104,
                                75000108, 2006, 75000103, 75000102, 75000113,
                                75000111, 75000109, 2001, 2009, 75000105,
                                75000107, 2004, 2010, 2013, 2014, 2005, 2011,
                                75000112, 2002, 1001, 2012, 75000106, 2007,
                                75000101, 2003, 75000110, 2008, 3001, 3002, 3019,
                                3104, 3020, 3105, 3021, 3106, 3022, 3107, 3023,
                                3108, 3024, 3109, 3025, 3110, 3026, 3111, 3027,
                                3112, 3028, 3113, 3029, 3114, 3030, 3115, 3031,
                                3116, 3032, 3117, 3033, 3118, 3034, 3119, 3035,
                                3120, 3036, 3121, 3037, 3122, 3038, 3123, 3039,
                                3124, 3040, 3125, 3041, 3126, 3042, 3127, 3043,
                                3128, 3044, 3129, 3045, 3130, 3046, 3131, 3047,
                                3132, 3048, 3133, 3049, 3134, 3050, 3135, 3051,
                                3136, 3052, 3137, 3053, 3138, 3054, 3139, 3055,
                                3140, 3056, 3141)
                        AND req.pa_rqst_sid = prs.pa_rqst_sid
                        AND prs.oprtnl_flag = 'A'
                        AND prs.pa_rqst_srvc_sid = psd.pa_rqst_srvc_sid
                        AND psd.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = pci.pa_rqst_sid
                        AND pci.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = prxm.pa_rqst_sid
                        AND prxm.oprtnl_flag = 'A'
                        AND md.oprtnl_flag = 'A'
                        AND md.status_cid = 2
                        AND TRUNC (SYSDATE) BETWEEN md.from_date AND md.TO_DATE
                        AND prxm.mbr_sid = md.mbr_sid
                        AND ou.org_unit_sid = req.org_unit_sid
                        AND ou.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND prxm.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND pci.pa_rqst_sid = prxm.pa_rqst_sid
                        AND pci.pa_rqst_sid = wmdtl.subsystem_task_sid
                        AND pci.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND prxpl.pa_prvdr_type_lkpcd = 'RR'
                        AND prxpl.oprtnl_flag = 'A'
                        AND req.status_cid = sts.status_cid
                        AND sts.status_type_cid = 3
                        AND sts.oprtnl_flag = 'A'
                        AND prxpl.prvdr_lctn_iid = pl.prvdr_lctn_iid
                        AND p.prvdr_sid = pd.prvdr_sid
                        AND p.prvdr_sid = pl.prvdr_sid
                        AND pd.oprtnl_flag = 'A'
                        AND pd.status_cid = 2
                        AND TRUNC (SYSDATE) BETWEEN pd.from_date AND pd.TO_DATE
                        AND wmdtl.subsystem_task_sid = req.pa_rqst_sid
                        AND wmdtl.subsystem_lkpcd = 'PA'
                        AND wmdtl.oprtnl_flag = 'A'
                        AND req.pa_rqst_date > (SYSDATE - 365)
                                       ORDER BY TO_DATE ("Request Date", 'MM/dd/yyyy hh24:mi:ss') DESC,
                            "Beneficiary Name" ASC) a
    WHERE ROWNUM < 102;regards,
    P Prakash
    Edited by: BluShadow on 17-May-2011 15:01
    added {noformat}{noformat} tags around the code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    833560 wrote:
    Can any one give me clue ,how to find out which sub query returns more than one row in the following query .This is why smaller, simpler queries are easier to work with than huge ones - when something like this goes wrong smaller queries are much eaiser to debug. Unfortunately using smaller, easier-to-work with queries is not always an option
    Ganesh is right - you will have to dissect the big query bit by bit until you find the offending subquery. If there is another way I would like to find out about it too.
    The easiest way to do this is probably to use block comments to isolate parts of the query bit by bit until you find the offending part. If you carefully examine the subqueries you might be able to figure out which one is returning multiple rows without commenting everything
    Good luck!

  • Possible to return more than one value?

    If I have a somethign like this:
    public int test()
    return 5;
    }Is it possible to have test() return more than one value? And if it can, can you post an example showing how?

    Could you post an example of how to do this?If you do not know how to define a class, you need to start from the very beginning.
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java.
    James Gosling's The Java Programming Language. Gosling is
    the creator of Java. It doesn't get much more authoratative than this.

  • Subquery returned more than one value

    Hi,
    I have this statement which has been working fine - not I get a 'Subquery returned more than one value" error:
    SELECT
    'WAS3' AS 'Rec ID',
    E.EecEEID AS 'Emp ID',
    eepNameFirst AS 'First Name',
    eepNameLast AS 'Last Name',
    EecDateOfOriginalHire AS 'Service Date',
    (SELECT DATEDIFF(YEAR, EecDateOfOriginalHire, getdate()) from empcomp EC WHERE EC.EecEEID = E.EECEEID) as 'Yrs of Serv'
    FROM
    EmpPers
    JOIN EmpComp E
    ON E.eecEEID = eepEEID
    JOIN Company
    ON eecCoID = cmpCoID
    WHERE
    EecDateOfTermination IS NOT NULL
    AND EXISTS
    (SELECT 1
    FROM EmpComp e2
    WHERE e2.EecEEID = E.EecEEID
    --AND e2.eecEmplStatus <> 'A')-- changed to <> ...this WAS/is to filter out anyone that was termed then re-hired
    --AND E.EecTermReason NOT IN ('I01','I02','I03','I14','I22','V05','V07','V09','V12','V22','V13', 'TRO')
    AND E.eecDateOfTermination
    IN (SELECT (EC.eecDateOfTermination)
    FROM EMPCOMP EC
    WHERE EC.EecEEID = E.EECEEID
    AND EC.eecDateOfTermination IS NOT NULL
    AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
    AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)
    AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
    AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)))
    --AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),0)
    -- AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),6)
    -- AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),0)
    -- AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),6)
    -- AND E.eecDateOfTermination IS NOT NULL ))
    --added below per Paul Cottle to exclude employeess less than four years
    AND E.eecdateoforiginalhire >=dateadd(year,-4, CURRENT_TIMESTAMP)
    qeqw

    Check this, if it works:
    SELECT
    'WAS3' AS 'Rec ID',
    E.EecEEID AS 'Emp ID',
    eepNameFirst AS 'First Name',
    eepNameLast AS 'Last Name',
    EecDateOfOriginalHire AS 'Service Date',
    DATEDIFF(YEAR, EecDateOfOriginalHire, getdate()) as 'Yrs of Serv'
    FROM EmpPers
    JOIN EmpComp E ON E.eecEEID = eepEEID
    JOIN Company ON eecCoID = cmpCoID
    WHERE EecDateOfTermination IS NOT NULL
    AND EXISTS
    (SELECT 1
    FROM EmpComp e2
    WHERE e2.EecEEID = E.EecEEID
    AND E.eecDateOfTermination
    IN (SELECT (EC.eecDateOfTermination)
    FROM EMPCOMP EC
    WHERE EC.EecEEID = E.EECEEID
    AND EC.eecDateOfTermination IS NOT NULL
    AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
    AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)
    AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
    AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)))
    AND E.eecdateoforiginalhire >=dateadd(year,-4, CURRENT_TIMESTAMP)
    If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

  • Can a method return more than one value?

    I was studying for my biology exam and I got bored and I started thinking and then I wandered if a method can return more than one value...?
    For example, if I want a method to return a row a column, I make a method that returns an int. But what if I want to return two ints? Or what If I want to return an integer and a string? Is it possible or do I have make two methods, each returning one thing?
    What I always did until now is is I want for example to return a few integers, I would store them in a String and then when I return the string, I parse the numbers out using stringtokenizer... but it doesn't look like the best way... and it's pretty annoying...

    I'm weak on terminology, hence I don't even know what
    AFAIK means...As Far As I Know
    This doesn't really make sense for me. It's more
    efficient to make a whole class just for two
    integers, than having two methods? Efficiency is not the point. The flow is.
    If you have two methods, the caller must be aware of both of them. The other way it's up to the callee.
    Just because the
    two integers are related to each other? Doesn't
    making a class require more memory usage than just
    making two one-line methods?The memory usage is not wholly irrelevant, but there are ways to handle that (caching, inlining, etc.).
    It's a bit hard to counter your point for me, but if you had done a lot of GUI painting stuff, you'd see all those Points, Dimensions, Rectangles, you name it, are quite invaluable.

  • LOV Return more than one value to differenent items on page

    New to express. I need to returm more than one value from list of LOV. For example: LOV => select a, b, c from testtable
    I would then like to
    a to populate item1 => with submit
    b to populate item2 => hidden
    c to pupulate item3 => hidden
    as items on my page
    when a user chooses a (with submit) in item1 b and c would populate also, b and c are hidden to the user. Any advice?

    Dear Frank
    I did it as like as the following link lead me:
    http://www.oracle.com/technology/obe/obe11jdev/11/adfbc_new_features/adfbc.html
    The problem has been appeared when I attached the "Create" button and when press on it to create new record, then the "LOV" couldn't work correctly.
    Thanks for your reply

  • How to return more than one value from a  function

    hello everybody,
    Can anyone tell me how to return more than a single value from a function, the problem is i have 4 points,
    2 points form one line ,another 2 points form 2nd line ,each point is 3 dimensional(x,y,z coorinates) so i will pass these values to func(x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4), i will find the point of intersecton of two lines and i will get it as x,y,z , now how to return these 3 coordinates,usually the function returns only one value, please help me to solve it out.
    Thanks.

    I think the easiest way or trick here is (easiest isn't always the best as we know, but atleast this one will work) to create simple data array. and pass that. Create an array with:
    <code>
    class justArray {
    int x=0
    int y=0;
    int z= 0;
    ...somewhere
    justArray[] points= new justArray[4];
    points[0].x= ..
    points[0].y= ..
    points[0].z= ..
    points[1].x= ..
    return points[]
    </code>

  • Function - Return More than One Value in a Concatenated String

    Hi,
    Is it possible for a function to return a concatenated string(combining more than one number). I am trying to return the PO number by inputting and invoice_id and code number but an invoice_id can have more than one PO with the same code number. I would like to concatenate the PO numbers with commas e.g.
    10124, 10090, 10987
    At the moment the function returns null for these cases that have more than one PO number.
    Thanks

    Also is is possible to create another function that can be called in the same script using the PO number as an IN parameter in SQL. See SQL below:
    select cck.concatenated_segments as "Segment" ,
    cc.code_combination_id,
    NVL ( src . user_je_source_name , '**********' ) AS "Source" ,
    NVL ( cat . user_je_category_name , '**********' ) AS "Category" ,
    jel . period_name as "Period Name" ,
    i.invoice_id as "Invoice ID",
    s.vendor_name as "Vendor Name",
    s.segment1 as "Supplier No",
    jeb . name as "Batch Name" ,
    func_get_po(i.invoice_id, cc.code_combination_id) "PO No",
    jeh . name AS "Header Name" ,
    jel . description AS "Description" ,
    jel.accounted_dr AS "Debit" ,
    jel.accounted_cr AS "Credit" ,
    NVL(jel.accounted_dr, 0) - NVL(jel.accounted_cr, 0) AS "Net Amount"
    FROM apps.gl_code_combinations cc ,
    apps.gl_code_combinations_kfv cck,
    apps.gl_je_lines jel ,
    apps.gl_je_headers jeh ,
    apps.gl_je_batches jeb ,
    apps.gl_je_categories cat ,
    apps.gl_je_sources src,
    apps.gl_import_references r,
    apps.xla_ae_lines al,
    apps.xla_ae_headers ah,
    apps.xla_events e,
    xla.xla_transaction_entities te,
    apps.ap_invoices_all i,
    apps.ap_suppliers s
    WHERE ( cck.concatenated_segments BETWEEN '23.83545.141.000.00.23.000.000' AND '23.83545.141.000.00.23.000.000'
    AND cc.CHART_OF_ACCOUNTS_ID = 50328
    AND jeh.LEDGER_ID IN
    (select acc.ledger_id
    FROM apps.gl_access_set_ledgers acc
    WHERE acc.access_set_id = 1000
    AND jel.code_combination_id = cc.code_combination_id
    AND cck.code_combination_id = cc.code_combination_id
    AND jel.status
    || '' = 'P'
    AND ( jel.accounted_dr != 0
    OR jel.accounted_cr != 0 )
    AND jeh.je_header_id = jel.je_header_id
    AND jeh.actual_flag = 'A'
    AND 1 = 1
    AND jeh.currency_code != 'STAT'
    AND jeb.je_batch_id = jeh.je_batch_id
    AND jeb.average_journal_flag = 'N'
    and src.je_source_name = jeh.je_source
    and cat.je_category_name = jeh.je_category
    and r.je_header_id(+) = jel.je_header_id
    and r.je_line_num(+) = jel.je_line_num)
    AND ( :period_name = jel.period_name
    and al.gl_sl_link_id(+) = r.gl_sl_link_id
    and al.ae_header_id = ah.ae_header_id(+)
    and al.application_id = ah.application_id(+)
    and ah.application_id = e.application_id(+)
    and ah.event_id = e.event_id(+)
    and e.application_id = te.application_id(+)
    and e.entity_id = te.entity_id(+)
    and nvl(te.source_id_int_1,-99) = i.invoice_id(+)
    and i.vendor_id = s.vendor_id(+) )
    AND ( jel.ledger_id = 2041)
    ORDER BY src.user_je_source_name ,
    cat.user_je_category_name ,
    jeb.name ,
    jeh.name ,
    cck.concatenated_segments ,
    jel.je_line_num
    I am using func_get_po(i.invoice_id, cc.code_combination_id), I would like to call another function in this script that uses the PO number as an IN parameter.
    For example func_get_po_requester(i.invoice_id, cc.code_combination_id, func_get_po(i.invoice_id, cc.code_combination_id))
    Would this work?
    Thanks

  • Return more than one value in a function

    Hi All,
    I want to return values from table. 4 values will be returned from the table.
    Did something like this....will work for a single row.
    CREATE OR REPLACE FUNCTION test_func
    RETURN varchar2
    IS
    temp1 varchar2(1);
    temp2 varchar2(1);
    temp3 varchar2(1);
    temp4 varchar2(1);
    v_strng_val varchar2(2000);
    BEGIN
    select '1','2','3','4' into temp1,temp2,temp3,temp4 from dual;
    v_strng_val := temp1;
    v_strng_val := v_strng_val||','||temp2;
    v_strng_val := v_strng_val||','||temp3;
    v_strng_val := v_strng_val||','||temp4;
    return v_strng_val;
    exception
    when others then
    return null;
    End test_func;I know this could be done through collections. But not worked on collections
    much.
    Please Suggest. Thanks.
    Edited by: user545846 on Jul 20, 2009 10:26 PM

    use refcursor you can do it.
    SQL> create or replace function get_dept_emps(p_deptno in number) return sys_refcursor is
    2 v_rc sys_refcursor;
    3 begin
    4 open v_rc for 'select empno, ename, mgr, sal from emp where deptno = :deptno' using p_deptno;
    5 return v_rc;
    6 end;
    7 /
    Function created.
    SQL> create or replace type emptype as object(empno number,
    2 ename varchar2(10),
    3 mgr number,
    4 sal number);
    5 /
    Type created.
    SQL> create or replace type t_emptype as table of emptype;
    2 /
    Type created.
    1 create or replace function populate_emps(deptno in number := null)
    2 return t_emptype is
    3 v_emptype t_emptype := t_emptype(); -- Declare a local table structure and initialize it
    4 v_cnt number := 0;
    5 v_rc sys_refcursor;
    6 v_empno number;
    7 v_ename varchar2(10);
    8 v_mgr number;
    9 v_sal number;
    10 begin
    11 v_rc := get_dept_emps(deptno);
    12 loop
    13 fetch v_rc into v_empno, v_ename, v_mgr, v_sal;
    14 exit when v_rc%NOTFOUND;
    15 v_emptype.extend;
    16 v_cnt := v_cnt + 1;
    17 v_emptype(v_cnt) := emptype(v_empno, v_ename, v_mgr, v_sal);
    18 end loop;
    19 close v_rc;
    20 return v_emptype;
    21* end;
    SQL> /
    Function created.
    SQL> select * from table(populate_emps(30));
    EMPNO ENAME MGR SAL
    7499 ALLEN 7698 1600
    7521 WARD 7698 1250
    7654 MARTIN 7698 1250
    7698 BLAKE 7839 2850
    7844 TURNER 7698 1500
    7900 JAMES 7698 950

  • How to return more than one value through RECORD TYPE from function

    Hi friends,
    i m ew in oracle forms. i want to return the two values at a time from a function but can't,Please help me. my codding is as following
    Thanks in advance.
    FUNCTION Fun_Choose_Right_cast(v_post_no payroll.post_register.post_no%TYPE) RETURN RECORD IS --here is the error 
    v_return_char CHAR NOT NULL := 'X';
    TYPE row_no_record_type IS RECORD
         (v_row_id NUMBER(3)NOT NULL := 0,
         v_char CHAR NOT NULL := 'X');
    row_no_record row_no_record_type;
    BEGIN
    IF v_post_no = 1 THEN
         IF TRUNC(v_post_no*0.15) >= 1 THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'A';
              --v_return_char := 'A';
         END IF;
         IF TRUNC(v_post_no*0.075) >= 1 THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'B';
              --v_return_char := 'B';
         END IF;
         IF TRUNC(v_post_no*0.275) >= 1 THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'C';
              --v_return_char := 'C';
         END IF;
         IF row_no_record_type.v_row_id = 0 AND v_char = 'X' THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'D';
         --IF v_return_char = 'X' THEN 
              --v_return_char := 'D';
         END IF;
    ELSIF(v_post_no BETWEEN 2 AND 100) THEN
         IF TRUNC(v_post_no*0.15) > TRUNC((v_post_no-1)*0.15) THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'A';
              --v_return_char := 'A';
         END IF;
         IF TRUNC(v_post_no*0.075) > TRUNC((v_post_no-1)*0.075) THEN
              IF TRUNC(v_post_no*0.15) > TRUNC((v_post_no-1)*0.15) THEN
                   row_no_record_type.v_row_id := v_post_no-1;
                   v_char := 'B';
                   --v_return_char := 'A';
              ELSE
                   row_no_record_type.v_row_id := v_post_no;
                   v_return_char := 'B';
              END IF;
         END IF;
         IF TRUNC(v_post_no*0.275) > TRUNC((v_post_no-1)*0.275) THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'C';
              --v_return_char := 'C';
         END IF;
         IF row_no_record_type.v_row_id = 0 AND v_char = 'X' THEN
              row_no_record_type.v_row_id := v_post_no;
              v_char := 'D';
         --IF v_return_char = 'X' THEN 
              --v_return_char := 'D';
         END IF;
         END IF;
    RETURN row_no_record;
    END;

    Posting your Oracle version is immensely helpful when asking questions (different version = different answers / functionality available).
    select * from v$version;Also, using tags will preserve the formatting of your code.
    You should likely read (a lot) about  [http://www.stanford.edu/dept/itss/docs/oracle/10g/appdev.101/b10807/05_colls.htm]
    Basically, you would need to create a PL/SQL record and reference that, OR you could create a SQL type.
    If you're looking for a 'simple' way to return many single values (no arrays) then your best bet would be a procedure with multiple OUT parameters.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Output parameters or how to return more than one value

    My RMI server retrieves a list of Strings from the database. I need to return a status code int and an array of Strings to the RMI client. Does anybody have any ideas on how to do this. The only way I have come up with is to return an array of Strings using the first array position as the status code. But this is very ugly. There doesn't seem to be any way to have output parameters. I can use "output parameters" with code that lies in the same app by using wrapper classes or arrays but this does not really apply to a client and server running on different machines. Any ideas?

    Well, my general reaction is that you don't need a status code. (You can instead throw an exception if the status is anything but "OK".)
    However, on the assumption that you really DO need the status, then some alternatives are
    o Return an object that has a status code and an array as member variables.
    o In the call, pass in an object that the server can fill in with the array of strings. have the function return the status code.

  • Creating a popup to return more than one value

    Hi
    I am trying to create a POPUP item on my page.
    I have created a List of Values with the following queries
    select NAME d, ID r from EMPLOYEE order by 1
    The page displays a text box with a popup icon adjacent to it.
    On clicking the popup icon the popup window displays the name of all the employess in order, on choosing the employee the Id of the employee gets populated into the text box; I would like the name to be displayed on the text box.
    I also would like to have the employee name to be available in the page. Is this possible?
    The current popup is similar to the select list. I would like to obtain both the values from my popup window i.e the employee name and employee id into my page. So that I can display the employee name to the user but while submitting the page i can pass the employee id.
    Can you give me some suggesstions as to how to achieve this.
    Thanks.
    Message was edited by:
    KART

    Hmm, can't think it's going to be possible to pass back two values from a standard popup. One option:
    Use a standard popup and set its SQL to something like:
    SELECT employee d, (employee || ' ( ' || id || ')') r FROM employee;
    This will populate your item with something like: Smith (0122345)
    Assuming the item with the popup is called :P1_MYITEM, you could then reference the ID of the employee in a PL/SQL process when the page is submitted, something like:
    emp_id := substr(:P1_MYITEM,instr(:P1_MYITEM,'(')+1,instr(:P1_MYITEM,')')-instr(:P1_MYITEM,'(')-1)
    Or you could use the same kind of code in a computation to set a hidden item to contain the employee's ID.
    It's not ideal but might do the trick depending exactly how rigid your requirements are.
    Andy

  • How do you return more than one value from a method?

    say I have this:
    public static int myFunc(String inString)
         // I want to return two values from this method
    }yeah so how would i do that?

    If the two values are somehow related--like a person's name and his age--define a class that has those two values as member variables--for example, Person. But only if that class and the assocation of those two quantities makes sense as an entity in your program. Don't do it just to jam to quantities into one return.
    Or, if the two values are two of the same thing--person A's age and person B's age--then you can return an array or Collection.
    If it doesn't fit either of those two scenarios, then your method is trying to do too much unrelated stuff and you should break it into multiple methods. For example, calculating a Person's age based on his birthdate and today's date and calculating his Body Mass Index based on his height and weight. Those two quantities should NOT be returned together.

Maybe you are looking for

  • ABAP Mapping Programm error  Urgent

    I am getting mapping error in ABAP Mapping programm. plz help me how to solve <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> - <!-- Request Message Mapping   --> - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://sc

  • Imac freezes with horizontal green lines

    My Imac crashed the other day with green lines horizontally across the screen, the mouse would react and move around, but could not open any apps. We took it to get repaired at Core Mac and he said it worked fine. We brought it home today and it cras

  • How do I get the address bar to not have faded out parts?

    I just let firefox update itself, and now my address bar is all faded except for the domain name. This is annoying, as it's harder to read the rest of the URL. How do I get it back to normal?

  • Clear Customer with cheque reference at BRS

    Hi, At the time of BRS FF67, can we clear Customer account with Cheque as reference? If so how the system will findout the particular Open Item? i mean, how the system will know that this cheque is to this particular Open Item, and clear it. I know w

  • Do i have to activate all channels one at a time

    do i have to activate all channels one at a time with Apple TV or is there a global activation