TimesTen SQL with group by returning multiple rows

I have a Active-Standby TimesTen nodes.
Using group by with or without having clause:
Whenever I do a group by query on table1 table with or without having clause, SQL returns multiple rows. This looks very strange to me. Each time it gives different count
Command> select count(*) from table1 group by pname having pname='pool';
< 390400 >
1 row found.
Command> select count(*) from table1 group by pname having pname='pool';
< 390608 >
< 32639 >
2 rows found.
Command> select count(*) from table1 group by pname having pname='pool';
< 2394 >
< 351057 >
2 rows found.
Command> select count(*) from table1 group by pname having pname='pool';
< 305732 >
1 row found.
Command> select count(*) from table1 group by pname having pname='pool';
< 420783 >
1 row found.
Command> select count(*),pool_name from root.rms_address_pools group by pool_name order by pool_name;
< *435473, pool* >
< *32313, pool* >
< 453, smvG3 >
< *28980, pool* >
< 3786, smvG4 >
< *26025, pool* >
< 236120, smvG6 >
< 131455, smcG3 >
< *65150, pool* >
< 23, snt1G1 >
< 510, snt2G1 >
< 510, snt2G2 >
Using where clause:
Command> select count(*) from table1 where pname='pool';
< *442354* >
1 row found.
Command> select count(*) from table1 where pname='pool';
< 442354 >
1 row found.
Table description:
Command> desc table1;
Table table1:
Columns:
*IP_ADDRESS                      BIGINT NOT NULL
PNAME CHAR (32) NOT NULL
SITEID TINYINT NOT NULL
1 table found.
ttVersion:
bash-3.00# ./ttVersion
TimesTen Release *7.0.3.1.0 (64 bit Solaris)* (tt70:17001) 2007-10-30T22:17:07Z
Instance admin: root
Instance home directory: /TimesTen/tt70
Daemon home directory: /var/TimesTen/tt70
bash-3.00#
Could any one suggest what is wrong with my SQL? or is it a bug with TimesTen?
Many thanks in advance.
Br,
Brij

Hi Gena,
When i execute the query with where clause, it gives me the output with more than one pool:
Command> select pname, count (*) from table1 where pname='pool' group by pname ;
< smcG3 , 18836 >
< pool , 423527 >
2 rows found.
Command> select pname, count (*) from table1 where pname='pool' group by pname ;
< intG302 , 17202 >
< pool , 425159 >
2 rows found.
While if give use the having clause it gives me multiple rows for one pool only ( sometimes) :
select pname, count (*) from table1 group by pname having pname='pool';
< pool , 32686 >
< pool , 420445 >
2 rows found.
select pname, count (*) from table1 group by pname having pname='pool';
< pool , 393574 >
< pool , 5838 >
< pool , 110943 >
3 rows found.
Command> select pname, count (*) from table1 group by pname having pname='pool';
< pool , 414590 >
< pool , 8395 >
2 rows found.
Please suggest what can be done in this case, need i open a case with Oracle for this.
Regards, Brij

Similar Messages

  • Problem with database control returning multiple rows as Array  using Oracle

    Has anybody using Oracle gotten a Database control that
    returns multiple rows to work returning an array?
    The only way I can seem to return multiple rows is by returning
    a RowSet. Returning an array gives me a NullPointerException
    (when called within a pageFlow). When calling a database control
    that returns an array from a web service I get a
    "java.sql.SQLException: ResultSet has no more data." error.
    The samples using the pointbase database seem to work, but when I
    converted the CustomerDBClient web service to use Oracle, it starts
    failing on calling the database control that returns an array
    with: "java.sql.SQLException: ResultSet has no more data."
    Has anybody gotten this to work using Oracle?
    I'm also having some problem returning an Iterator. It seems
    to work when called from a web service, but returns nothing
    if called from a page flow.
    I'm using Oracle 8.1.7 and WebLogic 8.1.
    Eric

    Do you need a particular service pack installed to return an array of custom object?
    I am getting a ResultSet contained no data error when trying.
    Thanks,
    -Thomas
    "Robin Karlin" <[email protected]> wrote:
    >
    Eddie O'Neil <[email protected]> wrote:
    All--
    Unfortunately, returning an Iterator to a JPF (or JSP) from a
    database control is broken in WLW 8.1, though it will work inside of
    a
    JWS or JCS.
    There shouldn't be a problem with returning an array of objects out
    of Oracle to the JPF, and if you need an Iterator specifically, youcan
    wrap the array in an Iterator implementation.
    Sorry for the inconvenience.
    Eddie
    Lenny wrote:
    I have gotten it to work on Oracle using Array:)
    However, I haven't gotten it to work on Oracle using Iterator:( Itis so
    simple, but doesn't work:(
    "Eric Dokken" <[email protected]> wrote in message
    news:[email protected]...
    Has anybody using Oracle gotten a Database control that
    returns multiple rows to work returning an array?
    The only way I can seem to return multiple rows is by returning
    a RowSet. Returning an array gives me a NullPointerException
    (when called within a pageFlow). When calling a database control
    that returns an array from a web service I get a
    "java.sql.SQLException: ResultSet has no more data." error.
    The samples using the pointbase database seem to work, but when I
    converted the CustomerDBClient web service to use Oracle, it starts
    failing on calling the database control that returns an array
    with: "java.sql.SQLException: ResultSet has no more data."
    Has anybody gotten this to work using Oracle?
    I'm also having some problem returning an Iterator. It seems
    to work when called from a web service, but returns nothing
    if called from a page flow.
    I'm using Oracle 8.1.7 and WebLogic 8.1.
    Eric
    I get the same error that Eric reported when trying to return an Array
    of objects.
    It is really frustrating because I can't use much of the built-in control
    logic
    that WLW provides. All I did was create a data pool for Oracle and a
    datasource.
    I modified the sample app in C:\bea81\weblogic81\samples\workshop\SamplesApp\WebApp\callJavaControl
    to point to that datasource and I get the error that Eric reports above.
    Can
    anyone help me out????
    Thanks,
    Robin

  • Pl/sql block returning multiple rows

    Hi,
    I've created a plsql block which obtains an id from a name and then uses this id in another sql statement. The select statement to get the id works fine and the correct id is placed into the variable awardID.
    when i try to use this variable in another select statement it returns multiple rows. but when i just use the id in the select statement it works fine.
    select AwardID into awardID
    from award_objtabA
    where Name = awardName;
    this returns the correct id '5999'
    select Points into award_points
    from award_objtabA
    where AwardID = awardID;
    this returns multiple rows
    select Points into award_points
    from award_objtabA
    where AwardID = 5999;
    this works fine
    can anybody help with this confusing error?
    Cheers

    select AwardID
      into awardID               <= the same column
      from award_objtabA
    where Name = awardName;
    this returns the correct id '5999'
    select Points
      into award_points
      from award_objtabA
    where AwardID = awardID;    <= the same column
    this returns multiple rows
    to solve use different name not exactly the same as that of the column name
    select AwardID
      into vAwardID        
      from award_objtabA
    where Name = awardName;
    select Points
      into award_points
      from award_objtabA
    where AwardID = vAwardID;as Alex and Kamal have suggested use different name for your variable.

  • JDeveloper + WebServices, RETURN multiple rows from pl/sql

    I need to return multiple rows from pl/sql procedure or function and publish it as a Web Service through JDeveloper.
    I try to use ref cursor, but then found that it is impossible to use ref cursor as a return value in Web Services.
    Please, help me to achieve result.

    Hello. I tried to make commands from article, but got errors
    "C:\Program Files\Java\jdk1.6.0_18\bin\java" -jar D:\oracle\Middleware\oracle_common\modules\oracle.webservices_11.1.1\wsa.jar -plsqlAssemble -appName Echo -sql wo -dataSource jdbc/OracleManagedDS -dbConnection jdbc:oracle:thin:@192.168.246.2:1521:data -dbUser syd/manager -style rpc -use encoded
    Error: Interface oracle.generated.wo: The class could not be loaded from the class path.

  • Print Child SQL which is returning multiple rows to single colum.

    I have a requirement to print both Parent and Child SQLs rows to single row.
    For Ex:
    Parent row is returning single row
    Id, Name, Primary Rate.
    101, LName,FName ,30
    Child row is returning multiple rows
    Id, Name, Secondary Rate
    101, LName,FName,15
    101, LName,FName,10
    The end result should be
    101,LName,FName,30,15,10
    Any suggestions please?

    Below is the XML TAG
    <LIST_EMPLOYEERATE>
    <EMPLOYEERATE>
    <EMPNUMBER>112</EMPNUMBER>
    <EMPNAME>Aaron</EMPNAME>
    <PAYRATE>38.09</PAYRATE>
    <JOBNAME>Technician</JOBNAME>
    <EMPTYPE>Salary</EMPTYPE>
    <LIST_ADDRATE>
    <ADDRATE>
    <ADDPAYRATE>26</ADDPAYRATE>
    </ADDRATE>
    <ADDRATE>
    <ADDPAYRATE>7.9</ADDPAYRATE>
    </ADDRATE>
    </LIST_ADDRATE>
    </EMPLOYEERATE>
    </LIST_EMPLOYEERATE>
    The Result should be (assume this is going onto excel spread sheet)
    EmpNum EmpName Rate EmpType Rate1 Rate2
    112 Aaron 38.09 Salary 26 7.9
    Using @inline we are able to get 26 and 7.9 on the same line, but how to push 7.9 to next column?
    Thanks!

  • PL-SQL Returning multiple rows

    hi all
    i am using an oracle 8i database.My front end application is a JSP code which calls an oracle procedure.How do i pass a pl-sql table or an equivalent to a jave code since the procedure has to return multiple rows.i have been told that the jdbc driver version
    (1.0) which we are using does not support this.
    should i go about it differently and use temporary tables?..please help
    thanks
    LA

    hi all
    i am using an oracle 8i database.My front end application is a JSP code which calls an oracle procedure.How do i pass a pl-sql table or an equivalent to a jave code since the procedure has to return multiple rows.i have been told that the jdbc driver version
    (1.0) which we are using does not support this.
    should i go about it differently and use temporary tables?..please help
    thanks
    LA

  • The simplest way for plsql procedure to return multiple rows

    Hi,
    What is the simplest way for plsql procedure to return multiple rows (records). There are many combination of ways to do it but I am looking for a solution that is appropriate for plsql beginners. Many solutions use cursors, cursor variables, collections and more that kind of things that are complex on the face of it. Is it somehow possible to achieve the same with less effort?
    Sample query would be: SELECT * FROM EMPLOYEES;
    I want to use returned rows in APEX to compose APEX SQL(in that context plsql) report.
    It is enough to use just SELECT * FROM EMPLOYEES query in APEX but I want to use plsql procedure for that.
    Thank you!

    Hi,
    It depends :-).
    With +...that is appropriate for plsql beginners...+ in mind... it still depends!
    The list of techniques (ref cursors, cursor variables, collections, arrays, using explict SQL) you have referenced in your post can be made to work. but...
    +Is it somehow possible to achieve the same with less effort?+ Less effort : That needs to be defined (measured). Especially in the context of pl/sql beginners (who is a beginner?) .
    What is the level of "programming experience" ?
    What is the level of understanding of "Relational Result set" as processible in Oracle?
    If you are looking for
    Process_the_set_of rows_in APEX () kind of capabilitywhich "abstracts/hides" relation database from developers when working on relation database, it may not be the best approach (at least strategically). Because I believe it already is abstracted enough.
    I find REF CUROSOR most effective for such use, when the "begginer" has basic understanding of processing SQL result set .
    So in a nut shell, the techniques (that you already are familiar with) are the tools available. I am not aware of any alternative tools (in pure Oracle) that will simplify / hide basics from develpers.
    vr,
    Sudhakar B.

  • Custom database functoid to return multiple rows from database

    Hi,
    I have created a custom database fucntoid to execute a stored procedure which returns just single row from the database.But I could not manage to return multiple rows from the database.
    Does anyone know how to return multiple rows from DB and create a node with that many occurrences in the target schema?
    Thanks
    JB

    If you want to do this in messaging-only way without orchestration, then only option let to you is using .NET in BizTalk:
    We had similar requirement with one of our clients, where they didn’t want to use orchestration (though we emphasised on less impact orch would have compared to manageability),
    they still wanted to have pure-messaging only.
    We extended the custom XslTransform component that ships with BizTalk SDK (<BizTalk installation directory>\SDK\Samples\Pipelines\XslTransformComponent)).
    Created a custom disassembler pipeline component, used the XslTransform component from SDK to execute the map’s XSLT. Here we created a map with every links except the database ones. After executing the map, access the database, execute the store procedure
    which returns more than one row/dataset, enrich the XSLT transformed message with the dataset from your database in disassembler.
    Since .NET gives you the flexibility of access the dataset with more than one row, you can enrich the message in custom pipeline code.
    Other option is code the message transformation completely in .NET code in custom disassembler by passing the received message to method/code which would code the map/enrichment.
    While enriching you can execute the store procedure which returns more than one row/dataset, enrich the message further with the dataset from db.
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • Procedure from PowerBuilder returning multiple rows

    In want to call a procedure from PowerBuilder which return multiple rows. I would like to know how to write the procedure and also how to call it. I tried using REFCURSOR , but i heard that Powerbuilder doesnot support REFCURSOR . Please help
    Thanks in advance

    This is not a PL/SQL qustion, but a Powerbuilder question.
    Just what SQL constructs does Powerbuilder supports? And if there is no support for ref cursors, then the choice of using a client language that lacks basic core SQL support is questionable.

  • Insert statement with subquery to insert multiple rows

    Hi frnds,
    Kindly find the below mentioned query and error. Also suggest me to go ahead.
    SQL>  INSERT INTO FM_TRAN_DOC_NO (TDOC_COMP_CODE,
      2                               TDOC_TRAN_CODE,
      3                               TDOC_ACNT_YEAR,
      4                               TDOC_CUR_NO,
      5                               TDOC_MAX_NO,
      6                               TDOC_CAL_YEAR,
      7                               TDOC_PERIOD,
      8                               TDOC_DIVN_CODE,
      9                               TDOC_DEPT_CODE,
    10                               TDOC_CR_UID,
    11                               TDOC_CR_DT,
    12                               TDOC_UPD_UID,
    13                               TDOC_UPD_DT)
    14     SELECT    '001',
    15               (SELECT DISTINCT TDOC_TRAN_CODE FROM FM_TRAN_DOC_NO
    16               '6',
    17               '0',
    18               '9999',
    19               NULL,
    20               NULL,
    21               NULL,
    22               NULL,
    23               'AGT',
    24               TO_DATE (SYSDATE),
    25               NULL,
    26               TO_DATE (SYSDATE) FROM DUAL;
                 (SELECT DISTINCT TDOC_TRAN_CODE FROM FM_TRAN_DOC_NO ),
    ERROR at line 15:
    ORA-01427: single-row subquery returns more than one row

    This "SELECT DISTINCT TDOC_TRAN_CODE FROM FM_TRAN_DOC_NO" query returns multiple rows. So what is your requirement?
    Try the below insert if you want to select from tale FM_TRAN_DOC_NO
    INSERT INTO FM_TRAN_DOC_NO (TDOC_TRAN_CODE,
                                TDOC_COMP_CODE,
                                 TDOC_ACNT_YEAR,
                                 TDOC_CUR_NO,
                                 TDOC_MAX_NO,
                                 TDOC_CAL_YEAR,
                                 TDOC_PERIOD,
                                 TDOC_DIVN_CODE,
                                 TDOC_DEPT_CODE,
                                TDOC_CR_UID,
                                TDOC_CR_DT,
                                TDOC_UPD_UID,
                                TDOC_UPD_DT)
      SELECT    DISTINCT
                TDOC_TRAN_CODE
                '001',
                '6',
                '0',
                '9999',
                NULL,
                NULL,
                NULL,
                NULL,
                'AGT',
                TO_DATE (SYSDATE),
                NULL,
                TO_DATE (SYSDATE) FROM TDOC_TRAN_CODE;
    Message was edited by: 000000

  • How to create a function that returns multiple rows in table

    Dear all,
    I want to create a funtion that returns multiple rows from the table (ex: gl_balances). I done following:
    -- Create type (successfull)
    Create or replace type tp_gl_balance as Object
    PERIOD_NAME VARCHAR2(15),
    CURRENCY_CODE VARCHAR2(15),
    PERIOD_TYPE VARCHAR2(15),
    PERIOD_YEAR NUMBER(15),
    BEGIN_BALANCE_DR NUMBER,
    BEGIN_BALANCE_CR NUMBER
    -- successfull
    create type tp_tbl_gl_balance as table of tp_gl_balance;
    but i create a function for return some rows from gl_balances, i can't compile it
    create or replace function f_gl_balance(p_period varchar2) return tp_tbl_gl_balance pipelined
    as
    begin
    return
    (select gb.period_name, gb.currency_code, gb.period_type, gb.period_year, gb.begin_balance_dr, gb.begin_balance_cr
    from gl_balances gb
    where gb.period_name = p_period);
    end;
    I also try
    create or replace function f_gl_balance(p_period varchar2) return tp_tbl_gl_balance pipelined
    as
    begin
    select gb.period_name, gb.currency_code, gb.period_type, gb.period_year, gb.begin_balance_dr, gb.begin_balance_cr
    from gl_balances gb
    where gb.period_name = p_period;
    return;
    end;
    Please help me solve this function.
    thanks and best reguard

    hi,
    Use TABLE FUNCTIONS,
    [http://www.oracle-base.com/articles/9i/PipelinedTableFunctions9i.php]
    Regards,
    Danish

  • Stored Procedure Returning Multiple Rows

    Hello. Where can I find sample code from a class that calls a stored procedure that returns multiple rows?
    I have a servlet that calls the DB directly from the servlet & loops through the result set. I want to put that code into a stored procedure, but I'm not sure how to loop through the results.
    Your help is greatly appreciated!

    Surely you would call the stored procedure and loop
    through the resultset as usual.
    all that is different is the method by which you obtain the resultSet .
    assuming CallableStatement, Connection have been
    instantiated.
    cstmt=con.prepareCall("{call sp_NewOfficeSurgery (?,?)}");
    cstmt.setString(1,"first");
    cstmt.setString(2,"second");
    rs = cstmt.executeQuery();
    while (rs.next())
    String nme = rs.getString(1)
    etc,etc
    Hope this helps , Sorry If I have misinterpreted this
    please let me know if my thinking is floored or you need
    further clarification ect.
    [email protected]

  • How to check if "fetch" returns Multiple rows

    I want to know thru some variable (like %found) if the "fetch" returns multiple rows. How can I do it?
    My code:
    open      tab1_rec for
         'select fld1 '                ||
         'from     tab1 f '               ||
         'where     f.fld3 = :s1 and '     ||
         'f.fld4 = :s2 and '          ||
         'f.fld5 = 1 '
         using     fld3_in,
              fld4_in;
         fetch     tab1_rec into var1;
    -- If MULTIPLE
         if      tab1_rec%multiple
    Thanks

    If returning more than one row is unusual in some way (that is you are expecting only a single row) then you can do it like:
    BEGIN
       SELECT fld1 INTO var1
       FROM tab1 f
       WHERE f.fld3 = fld3_in and
             f.fld4 = fld4_in and
             f.fld5 = 1;
       < Do your processing here >
    EXCEPTION
       WHEN NO_DATA_FOUND THEN
          < handle no rows >
       WHEN TOO_MANY_ROWS THEN
          < handle multiple rows >
    END;No need for a cursor here. If you are expecting more than one row, and just want to know the count for information purposes, then you have to loop and fetch the records.
    HTH
    John

  • Returning Multiple Rows From DBAdapter Calling PL/SQL Procedure

    Oracle XE 10g Express Edition
    JDeveloper 11.1.1.2.0
    WebLogic Server 11g
    Guys,
    I have a table of orders, which I need to interrogate, and pass back any matching rows which meet certain criteria (e.g. status = 'OPEN').
    However, rather than create a DBAdapter using an Operation Type of "Peform an Operation on a Table/Select", I need to use an Operation Type of "Call a Stored Procedure or Function".
    I therefore need the procedure to return all the matching rows, rather than a single row.
    I have looked at declaring return parameters for the procedure of the following types:
    RECORD - is good because it allows me to return the elements of the row with their correct datatypes, but does not meet my needs because it will only support the return of a single row.
    VARRAY - good because it can contain many row elements, but not good because it only supports a single row return, and also because all elements of the VARRAY must be of the same data type.
    TABLE - good because it can contain many rows, but bad because each row can contain only two elements - the index element and the data element.
    I think I could first define a RECORD (to hold a row), and then define a TABLE, with the data element being the RECORD, but I have found JDeveloper very fussy indeed when dealing with 'non-standard' data types in the DBAdapter.
    Apologies if I am missing something obvious, but can anyone suggest a way of doing this?
    Many thanks in advance.
    Edited by: user2541290 on 17-Feb-2010 02:48

    Hi, I've been able to create process that seems to work. My platform is a but different but I don't think this is important for your question.
    Here is the PL/SQL code. Just make Db Adapter for Calling stored procedure and it returns all rows!
    Be aware of possible limitations on how manyrows you could return in one select! This can have severe impact on performance.
    Succes.
    Jos Baan
    CREATE OR REPLACE PACKAGE lab2_multiple_rows IS
    -- Author : 801455
    -- Created : 18-2-2010 8:05:52
    -- Purpose :
    -- Public type declarations
    TYPE rrows IS RECORD(
    mutdat DATE,
    opmerking VARCHAR2(20));
    TYPE trows IS TABLE OF rrows INDEX BY BINARY_INTEGER;
    -- Public constant declarations
    -- Public variable declarations
    -- Public function and procedure declarations
    FUNCTION retrows RETURN trows;
    END lab2_multiple_rows;
    CREATE OR REPLACE PACKAGE BODY lab2_multiple_rows IS
    -- Private type declarations
    -- Private constant declarations
    -- Private variable declarations
    -- Function and procedure implementations
    FUNCTION retrows RETURN trows IS
    lrows trows;
    lidx binary_integer := 1;
    BEGIN
    FOR rsql IN (SELECT t.* FROM jba_transactions t ORDER BY t.mutdat)
    LOOP
    lrows(lidx).mutdat := rsql.mutdat;
    lrows(lidx).opmerking := rsql.opmerking;
    lidx := lidx + 1;
    END LOOP;
    RETURN(lrows);
    END;
    BEGIN
    -- Initialization
    NULL;
    END lab2_multiple_rows;
    Edited by: Baan, Jos on 18-feb-2010 8:53

  • Is there a way in Oracle to return multiple rows as a single string?

    Hi gurus,
    I just got help from your guys fixing my dynamic sql problem. What I am doing in that function is to return a single string from multiple rows and I use it in the select statement. It works fine once the problem was solved. But is there any way in Oracle to do this in the select statement only? I have a table that stores incidents (incident_id is the PK) and another table that stores the people that are involved in an incident.
    Incident_table
    (incident_id number PK);
    Incident_people_table
    (incident_id number PK/FK,
    person_id number PK);
    Now in a report, I need to return the multiple rows of the Incident_People_table as a single string separated by a comma, for example, 'Ben, John, Mark'. I asked the SQL Server DBA about this and he told me he can do that in SQL Server by using a variable in the sql statement and SQL Server will auomatically iterate the rows and concatenate the result (I have not seen his actual work). Is there a similar way in Oracle? I have seen some examples here for some similar requests using the sys_connect_by_path, but I wonder if it is feasible in a report sql that is already rather complex. Or should I just stick to my simpler funcion?
    Thanks.
    Ben

    Hi,
    May be, this example will help you.
    SQL> CREATE TABLE Incident_Table(
      2    incident_id number
      3  );
    Table created.
    SQL> CREATE TABLE Person_Table(
      2    person_id number,
      3    person_name VARCHAR2(200)
      4  );
    Table created.
    SQL> CREATE TABLE Incident_People_Table(
      2    incident_id number,
      3    person_id number
      4  );
    Table created.
    SQL> SELECT * FROM Incident_Table;
    INCIDENT_ID
              1
              2
    SQL> SELECT * FROM Person_Table;
    PERSON_ID PERSON_NAME
             1 John
             2 Mark
             3 Ben
             4 Sam
    SQL> SELECT * FROM Incident_People_Table;
    INCIDENT_ID  PERSON_ID
              1          1
              1          2
              1          3
              2          1
              2          2
              2          4
    6 rows selected.
    SQL> SELECT IT.*,
      2    (
      3      WITH People_Order AS (
      4        SELECT IPT.incident_id, person_id, PT.person_name,
      5          ROW_NUMBER() OVER (PARTITION BY IPT.incident_id ORDER BY PT.person_name) AS Order_Num,
      6          COUNT(*) OVER (PARTITION BY IPT.incident_id) AS incident_people_cnt
      7        FROM Incident_People_Table IPT
      8          JOIN Person_Table PT USING(person_id)
      9      )
    10      SELECT SUBSTR(SYS_CONNECT_BY_PATH(PO.person_name, ', '), 3) AS incident_people_list
    11      FROM (SELECT * FROM People_Order PO WHERE PO.incident_id = IT.incident_id) PO
    12      WHERE PO.incident_people_cnt = LEVEL
    13      START WITH PO.Order_Num = 1
    14      CONNECT BY PRIOR PO.Order_Num = PO.Order_Num - 1
    15    ) AS incident_people_list
    16  FROM Incident_Table IT
    17  ;
    INCIDENT_ID INCIDENT_PEOPLE_LIST
              1 Ben, John, Mark
              2 John, Mark, SamRegards,
    Dima

Maybe you are looking for