How to return more than one record through OUT parameter in procedure

Hi,
I want to create a procedure which accepts one input and returns more than one record as output.
example:
Input = DeptNo
Output= Empno,ename,sal,comm,job
Scenario:
There can be more than one employee in department we pass as the IN parameter. OUT parameter has to return all the records of the corresponding employee details in that department.
Thanks in advance for your help
Regards,
K.Vijay

-- I think you can try something like this using ref cursor:
-- create a package for the type ref cursor and execute
CREATE OR REPLACE PACKAGE PACK_REFCURSOR_FOR_TABLES AS
     TYPE DATA_TableRows IS REF CURSOR;
END;
-- after executing the package above, create your procedure:
CREATE OR REPLACE PROCEDURE GET_EMP (
     IN_nDeptNo IN number,
     OUT_Emp OUT PACK_REFCURSOR_FOR_TABLES.DATA_TableRows)
IS
BEGIN
-- leave query open (implicit) as this will return data
     OPEN OUT_Emp FOR
     SELECT *
     FROM tblEmp
     WHERE DeptNo = IN_nDeptNo;
END;
--execute the procedure and you're done                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

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

  • How to show more than one record at a form-like style report?

    Hi All,
    I developed a form-like style report
    I want it to show more than one record at once (At the same page)
    I tried that by setting the value to "Maximum records per page" property for the repeating frame to 10
    but when I close the property palete and open it agian the value is returned to 1 !!!
    how to show more than one record at the same page?????
    Thank u

    Hi,
    there's perhaps another property like "page protect". If than 2 records didn't fit at one page there's a page break. Or is there any object inside the repeating frame with page-break properties? Sorry .. it's like looking into a chrystal ball ...
    Regards
    Rainer

  • How to display more than one Record in a Loop

    Hi ,
    This procedure will return more than one data .
    so please tell me how can i write a loop to display all the records of a Table .
    This is my procedure :
    create or replace procedure getEmpName
    V_EMPID IN employee.EMPID%TYPE,
    V_EMPNAME OUT employee.EMPNAME%TYPE
    is
    begin
    select empname into V_EMPNAME from employee where empid='2';
    end ;
    This is my block : How to write a loop here to display all records of my Table
    declare
    v_EMPNAME EMPLOYEE.EMPNAME%TYPE;
    begin
    getEmpName(2, v_EMPNAME);
    dbms_output.put_line(v_EMPNAME);
    end

    user10503747 wrote:
    so please tell me how can i write a loop to display all the records of a Table .hi,
    given procedure will display all records of emp table...
    CREATE OR REPLACE PROCEDURE Testloop
    AS
    CURSOR test1
    IS
    SELECT EMPNO, ENAME FROM EMP;
    BEGIN
         FOR i IN test1
         LOOP
         DBMS_OUTPUT.PUT_LINE ( 'Emp - '||i.empno ||'-'||i.ename );
         END LOOP;
    END;
    Thnx
    MB

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

  • How to update more than one records at one time

    hello guys..
    how to update a few records (more than one) with different
    IDs at the same time? i tried to make a query like this (see
    below), but only one record (more than one data in the same
    field)has been updated.
    <cfquery name="rec" datasource="DatKoku">
    select *
    from tbl_pilih
    where id_pel = '#form.idpel#'
    </cfquery>
    <cfquery name="updtrecord" datasource="DatKoku">
    update tbl_pilih
    set
    kptsn = '#form.suk_pil#',
    trkh_kptsn =
    '#Dateformat(TodayDate,"dd/mm/yy")#|#TimeFormat(Now(),"hh:mm:ss
    tt")#'
    where id_pel = '#rec.id_pel#'
    </cfquery>
    <cfquery name="outputrecord" datasource="DatKoku">
    select *
    from tbl_pilih
    where id_pel = '#form.idpel#'
    </cfquery>

    Take the query,
    <cfquery name="rec" datasource="DatKoku">
    select *
    from tbl_pilih
    where id_pel = '#form.idpel#'
    </cfquery>
    If every row in the table has a distinct id_pel, then what
    you ask is actually an impossible question. It will have no answer.
    Distinct IDs imply that the resultset will contain
    at most one distinct value of id_pel. That means, there can
    be at most one row that satisfies the condition,
    where id_pel = '#rec.id_pel#' in the update query. That in
    turn means the update query can update at most one row at a time.
    If, however, the resultset of
    rec consists of multiple rows, it will mean that there are
    multiple rows in the table that have the same
    id_pel . Then, your update query,
    updtrecord, should update all the rows that share that value
    of id_pel.

  • How to return more than one string?

    Hi,below is my code:
    @WebMethod(operationName = "CheckBooking")
    public String CheckBooking(@WebParam(name = "ID")
    String ID) {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:Flight");
    // Statement stmt = con.createStatement();
    String b="Select Destination, Date from Flight_Booking WHERE BookingID=?";
    PreparedStatement ps=con.prepareStatement(b);
    ps.setString(1,ID);
    ResultSet a = ps.executeQuery();
    //Print the data to the console
    while(a.next()){
    return a.getString(1);
    catch( Exception e ) {
    e.printStackTrace();
    return "a";
    Actually, I would like to select Destination and Date from the database, but if I set the return result as string, then only Destination will be return,how can I modify it so that both of the Destination and Date also will be return?As I know, .Net has a return type called Dataset, in Java what should I write?
    Actually,I am writing this web services to consume it on a table from .Net,so what is the most suitable to code it so that more than one string can be return?

    Create either a list or an array and assign your values to it and return it.
    arrays
    lists

  • How to Insert more than one record at a time- with fixed set of values in one field

    Can someone guide as to how to insert multiple records at a time using ASP VBScript in Dreamweaver CS4 or ADDT.
    If someone can guide then the exact problem is given below.
    I have a MS access database with one table. The table has three fields. The first field is an autonumber field for ID number.
    The second field contains string values- One out of 7 predefined values. One set of records consists of 7 records containing all the seven types of predefined values in fields no 1.
    The third field is a numeric field and can contain integers.
    I want that the user can enter data for the table using an ASP form in such a way that he enters one set of records at a time in one single screen. This way he will not have to remember that he has /has not entered all the seven set of values for the field no 1.
    I am not creating fields with the 7 types of field1value as their names as it will increase the number of fields drastically.
    Please help for dreamweaver ASP VBScript.

    I have successfully inserted seven records in one form submit operation by looping through the command object execute method.
    However, the data that is being inserted by the command object is repetition of the first record and the command object is not taking any data from the text boxes for the second record onwards. In this I had used the isert record behavious generated by DW CS4 and modified it to suit my requirement. However, the data inserted in the first row is getting repeated in all the seven rows.
    Please help.
    Also advise if there are any free dreamweaver server side validation extensions available.

  • How to Insert more than one record at a time

    How to insert multiple records at a time?
    If someone can advise on this, then the actual problem is described below:
    I have a MS access database with one table. The table has three fields. The
    first field is an autonumber field for ID number.
    The second field contains string values- One out of 7 predefined values. One
    set of records consists of 7 records containing all the seven types of
    predefined values in fields no 1.
    The third field is a numeric field and can contain integers.
    I want that the user can enter data for the table using an ASP form in such
    a way that he enters one set of records at a time in one single screen. This
    way he will not have to remember that he has /has not entered all the seven
    set of values for the field no 1.
    I am not creating fields with the 7 types of field1value as their names as
    it will increase the number of fields drastically.
    Please help with inserting multiple records at a time.

    I have successfully inserted seven records in one form submit operation by looping through the command object execute method.
    However, the data that is being inserted by the command object is repetition of the first record and the command object is not taking any data from the text boxes for the second record onwards. In this I had used the isert record behavious generated by DW CS4 and modified it to suit my requirement. However, the data inserted in the first row is getting repeated in all the seven rows.
    Please help.
    Also advise if there are any free dreamweaver server side validation extensions available.

  • How to return more than one object from SwingWorker

    I am using a SwingWorker to call 3 different methods of another class (data fetch class). Each of these 3 methods returns a String array. I am able to get the first array outside the thread code using the get() method of the SwingWorker class,
    final String tmpOrdNum = OrderNum;
    SwingWorker worker = new SwingWorker() {
         DATA_FETCH_TO_ARRAY data_fetch = new DATA_FETCH_TO_ARRAY(tmpOrdNum);
         public Object construct(){
              String [] orderArr = data_fetch.getHeaderArray();
              //String [] detailArr = data_fetch.getDetailArray();
              //String [] storeArr = data_fetch.getStoreArray();                    
              return orderArr;
         //Runs on the event-dispatching thread.
         public void finished(){     }
    worker.start() ;
    String[] testArr = (String[])worker.get();      //gets the header array
    /* HOW DO I GET THE DETAIL AND STORE ARRAYS HERE?*/I want to be able to call the other 2 methods of the data fetch class - getDetailArray() and getStoreArray() shown commented in the above code one by one.
    Can someone please suggest a way of doing this? Thank you.

    Return String[][] from construct method.
    Here is an example (observe test method):
    import java.util.*;
    public class ArrayTest{
         public static void main(String[] args){
              String[][] result=(String[][])new ArrayTest().test();          
              System.out.println("result1: "+Arrays.toString(result[0]));
              System.out.println("result2: "+Arrays.toString(result[1]));
              System.out.println("result3: "+Arrays.toString(result[2]));
         public Object test(){
              String[] str1={"A","B","C"};
              String[] str2={"M","N","O"};
              String[] str3={"X","Y","Z"};          
              String[][] out=new String[3][];
              out[0]=str1;
              out[1]=str2;
              out[2]=str3;
              return out;
    }Thanks,
    Mrityunjoy

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

  • How to return more than one varibles from a method?

    can you use the codes:
    return var1, var2,var3;
    If not, what is the correct way to do so? thanks.

    You can only return 1 object from a method in Java.
    However, this 1 object can contain multiple other objects. For example, a Vector object:
      public Vector someMethod() {
        Vector v = new Vector();
        v.add("abc");
        v.add("xyz");
        v.add("123");
        return v;
      }If these multiple objects are the same type, you can also use array to achieve want you want.
      public String[] someMethod() {
        String ss = new String[3];
        ss[0] = "abc";
        ss[1] = "xyz";
        ss[2] = "123";
        return ss;
      }--lichu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

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

  • How to concat columns from more than one record?

    I have a function that takes an Oracle long and returns it as a varchar so that I can use it in the Microsoft world. My problem is that the SELECT returns more than one row (which is valid) and I need the Long fields to be concatenated into the one varchar returned. Currently I get an error saying more than one record is returned. This is my function:
    CREATE or replace function m4owner.Get_Request_Text
    (av_REQUEST_ID varchar2, av_REQUEST_LINE number, av_TEXT_LINE_CODE varchar2)
    RETURN varchar2
    IS
    long_var LONG;
    BEGIN
    SELECT TEXT INTO long_var
    FROM M4OWNER.REQUEST_TEXT
    WHERE REQUEST_ID = av_REQUEST_ID
    AND REQUEST_LINE = av_REQUEST_LINE
    AND TEXT_LINE_CODE = av_TEXT_LINE_CODE;
    return long_var;
    END;

      CREATE or replace function m4owner.Get_Request_Text (av_REQUEST_ID varchar2,
                                                           av_REQUEST_LINE number,
                                                           av_TEXT_LINE_CODE varchar2) RETURN varchar2 IS
        long_var LONG;
      BEGIN
        for t1 in  (SELECT TEXT FROM M4OWNER.REQUEST_TEXT
                     WHERE REQUEST_ID = av_REQUEST_ID
                       AND REQUEST_LINE = av_REQUEST_LINE
                       AND TEXT_LINE_CODE = av_TEXT_LINE_CODE) loop
          long_var := long_var || t1.text;
        end loop
        return long_var;
      END; note: untested

  • How to apply data into 2 tables AND to more than one record in same table?

    Hello,
    I am trying to apply/insert data into 2 tables AND at the same time apply data to more than one record (in the same table). How would I do this in APEX?
    I have updated using one table with no problem, however, when I try updating with the two tables/ multiple record sets, I get errors.
    I appreciate the help.
    Thanks.
    Linda

    You can achieve what you want using PL/SQL. Can you post ur code?

Maybe you are looking for