Dynamic SQL rows to column

I have a table something like
                              WHERE    IN
                              Age           18
                              Year           2012,2013
                              Color         Blue
--etc
                              I would like to create a dynamic statement base on this table
                              Dyanmic SQL:
                              WHERE AGE IN (18) and Year IN (2012,2013) and Color IN (‘Blue’)
I am using SQL server 2008 R2. How can I do this using XML path or something

Here you go:
DECLARE @tbl TABLE ([WHERE]   sysname NOT NULL,
                     [IN]     nvarchar(200))
INSERT @tbl([WHERE], [IN])
   VALUES ('Age', '18'), ('Year', '2012,2013'), ('Colour', 'Blue,Yellow')
DECLARE @where nvarchar(MAX)
SELECT @where =
   (SELECT [WHERE] + ' IN (' +
            CASE WHEN [IN] LIKE '%[^0-9,]%'
                 THEN replace(quotename([IN], ''''), ',', ''',''')
                 ELSE [IN]
            END + ') AND '
    FROM   @tbl
    FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)') + ' 1 = 1'
SELECT @where
However, this is somewhat brittle. I'm assuming that a comma is a list separator; never part of a value searched for. I'm also assume that as long as a value is digits only, it is numeric, else it is a string. This would fail if there is a date value
on the form YYYYMMDD.
Probably you should store metadata somwhere, so that you know the data type of a column.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • Save a dynamic sql into a column

    Hello,
    I need to save dynamic SQL into a column called STR in a table.
    I have a insert into table A( id, fname, lname)
    values(1, 'John', 'Smith');
    I have a requirement to save the DML statement that user executed such as this insert statement into table 'A'.
    I have to save this into anoter table called 'B' in the 'STR' column.
    I have to save that whole insert statement into a cloumn 'STR' in table 'B'
    How can do this?
    Thank you..

    This is not for auditing. The shop wants to save the DML statements in a table when a user does updates and inserts.. at the same time they want to build dynamic sql for this as a string such as update emp set where empno = 1 etc....
    could you give me an example please.
    Thanks a bunch....

  • Transposing SQL rows to columns

    Hi All -
    I have a query which returns result set as follows:
    year      amt_type      amount
    2001 vacation 1000
    2001 medical 1000
    2001 college 15000
    2002 vacation 800
    2002 medical 1000
    2002 college 10000
    2003 vacation 400
    2003 medical 2000
    2003 college 80000.
    I am trying to make the years 2001, 2002, and 2003 as columns and trying to
    achieve the below output
    Amt type        2001       2002      2003
    vacation 1000 800 400
    medical 1000 1000 2000
    college 15000 10000 8000
    I am able to achieve this perfectly on client side. Right now I am trying to
    achieve the same through using SQL. I am using
    DECODE to achieve but my result set looks like below
    Amt type 2001 2002 2003
    vacation 1000
    vacation 800
    vacation 400
    medical 1000
    medical 1000
    medical 2000
    college 15000
    college 10000
    college 8000
    I am trying this on oracle. I am new to this concept. can anyone who worked in
    similar situation help me. Also, the years may change depending upon the dropdown
    selection on client page. Can I transpose rows to columns in SQL for dynamic
    values
    Thanks

    with t as (
               select 2001 year,'vacation' amt_type,1000 amount from dual union all
               select 2001,'medical',1000 from dual union all
               select 2001,'college',15000 from dual union all
               select 2002,'vacation',800 from dual union all
               select 2002,'medical',1000 from dual union all
               select 2002,'college',10000 from dual union all
               select 2003,'vacation',400 from dual union all
               select 2003,'medical',2000 from dual union all
               select 2003,'college',80000 from dual
    select  amt_type,
            sum(case year when 2001 then amount end) "2001",
            sum(case year when 2002 then amount end) "2002",
            sum(case year when 2003 then amount end) "2003"
      from  t
      group by amt_type
    AMT_TYPE       2001       2002       2003
    medical        1000       1000       2000
    college       15000      10000      80000
    vacation       1000        800        400
    SQL> SY.

  • Dynamically convert rows to columns

    I've looked at examples on asktom and here and so far everyone I've seen uses decode() or case() but in all cases you have to know the number of columns.. what if you don't?
    For example:
    select distinct storenbr, pslocation, monthdate, 0 as avg_tran
    from aopschedule.staffing_tran_detail, (select last_day(day) monthdate from days
    where day between to_date('02/01/2008','mm/dd/yyyy') and to_date('5/31/2008','mm/dd/yyyy'))
    where pslocation = '1110'returns
    STORENBR     PSLOCATION     MONTHDATE     AVG_TRAN
    34806     1110     2/29/2008     0
    34806     1110     3/31/2008     0
    34806     1110     4/30/2008     0
    34806     1110     5/31/2008     0But the date range is dynamic...
    So how do I account for this?
    I need this to look like
    storenbr     pslocation    feb    mar     apr    may
    12345        1234          0      0       0      0
    12399        2222          2      1       1      1
    ...I have Oracle 9i. Thanks
    Message was edited by:
    GM

    Hi,
    As Justin said, the number of columns is fixed when the query is compiled.
    Without doing dynamic SQL, you can provide for a worst case. For example, you can write a query that always has columns fro 12 months. If you run the query with parameters such that only three months are needed, the other nine columns will be NULL. This is not especially pretty, but it's relatively easy.
    You can do a truly dynamic querry In SQL*Plus. Instead of hard-coding a query such as
    SELECT storenbr
    , pslocation
    , SUM (DECODE (n, 1, cnt)) AS col_1
    , SUM (DECODE (n, 2, cnt)) AS col_2
    FROM staffing_tran_detail
    you can put the text shown in bold above (whether it's two columns, as in the example above, or three, or twelve) into a substitution variable. To define that substitution varibale dyamically, use the SQL*Plus "COLUMN ... NEW_VALUE" command, and run a preliminary query (which can be in the same script) to define the variable. If this involves concatenating multiple short rows of output into one very long row, there are a number of string aggregation techiques, such as the user-defined STRAGG function.
    Like Justin said, this is not trivial. If you're serious about doing it, post as much code as you can (such as a query with three hard-coded columns), and ask for help with the next step.

  • Dynamic SQL in Formula Column in OracleReports6i

    Following code is in formula column of my report. passing dynamic sql str1(actullay, this string comes from after parameter trigger form) into SQL and executing thru DBMS_SQL.PARSE function. it's failed with 'Fatal PL/SQL error occured' ...
    Coupld any one help me on this...
    function CF_1FORMULA0006 return Number is
    Credits1 NUMBER(10,2);
    str1 VARCHAR2(50) := 'AND b.PROGRAMID = 2 ';
    c1 INTEGER := dbms_sql.open_cursor;
    c2 INTEGER;
    begin
    begin
    dbms_sql.parse(c1,
    'SELECT NVL(SUM(a.AMOUNT),0) INTO Credits1' | |
    'FROM SPONSOR_TRAN_DATA a, SPONSOR b ' | |
    ' WHERE ' | |
    ' a.TRANTYPE = 41 ' | |
    ' AND a.SPONSORID = b.SPONSORID ' | |
    str1 | |
    'AND a.amount > 0 ' | |
    'AND a.timestamp >= :reportdate ' | |
    'AND a.timestamp < :reportdate + 1' ,2);
    c2 := dbms_sql.execute(c1);
    exception
    when no_data_found then
    Credits1 := 0;
    end;
    return Credits1;
    end;
    Thanks in advance......

    It looks like forms are not supporting text functions like FR yet, I gave it a try <<MemberName("<Formname>","<POV DIM Name>)>> in the formula header area and it didn't like it. It is just displaying what ever I typed in there.

  • Dynamic query, row to column

    Hi.
    Is any way to select one row as column for any table exists?
    I mean some script which have table name and condition as input parameters, and prints column_name || column value;
    I have tried to do it, but have some problems.
    e.g. have table
    create table my_table (column1 number, column2 number, column3 number);
    insert into my_table values (1,2,3);It should be something like:
    declare
    lv_table_name varchar2(40):='MY_TABLE'; /*these are input paremeters*/
    lv_condition varchar2(300):='column1=1;/*these are input paremeters*/
    begin
    /*body*/
    end;and output should be like (may use dbms_output)
    column1    1
    column2    2
    column3    3    Script should work for any table.
    Does anybody solves task similar to this?

    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:1035431863958
    Search for procedure print_table on that page.

  • Dynamic populate rows and columns in adf table

    Hi everybody !
    I have a query thats returns a unic value !
    and I want to populate an af:table with this value !
    i need to execute this query to get the values for each columns .... and jump to next row and continue to execute the query for new values of the columns of the new row !!!
    in backing bean ... im try to do someting like this :
    RichColumn coluna = new RichColumn();
    coluna.setId("id");
    HtmlOutputText out = new HtmlOutputText();
    out.setId("receive");
    out.setValue("Contas a Receber");
    coluna.getChildren().add(out);
    out = new HtmlOutputText();
    out.setId("pay");
    out.setValue("Contas a Pagar");
    coluna.getChildren().add(out);
    this.getTableFluxo().getChildren().add(coluna);
    but i get the same values for all the rows !!!!

    Hi there,
    If you use ADF BC you can make transient variable in the View Object and fill it in the get method,every time the
    get method is executed you will execute the query and change the value of the new transient variable.
    Even better solutions is to extend the query with this extra column and map the table with it.
    Regards,
    Alexander

  • Dynamic add row/columns to data forms(11.1.1.3) v/s (11.1.2.1)

    Hello All,,
    There used to be an option in Hyperion planning 11.1.1.3 to Dynamic add rows in data form. I don't see this option in planning 11.1.2.1 ?
    Could you please suggest how we can grant right users to add dynamic add rows and columns in data forms? or it is possible in 11.1.2.1 ?
    out user want to have a feature of adding row in data forms (planning forms)
    Thank you
    Edited by: 842804 on Aug 17, 2011 12:49 PM

    Do you mean 11.1.2, if so then adhoc web forms really take over from adding rows as they add much more functionality.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Dynamic add row/columns to data forms(11.1.1.3) v/s (11.1.1.2)

    Hello All,,
    There used to be an option in Hyperion planning 11.1.1.3 to Dynamic add rows in data form. I dont see this option in planning 11.1.1.2 ?
    Could you please suggest how we can grant right users to add dynamic add rows and columns? or it is possible in 11.1.1.2
    Thank you

    How about ad-hoc analysis? Have a read of this: http://download.oracle.com/docs/cd/E17236_01/epm.1112/hp_user/ch04s02s03.html
    Cheers,
    Mehmet

  • Dynamic SQL Pivoting(Converting Row to Columns)

    Hi All,
    I am using Oracle 9i (Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production)
    and also 10g version
    I am facing difficulties to find out the logic for
    converting the set of values in one of the columns into the column headings for the entire query.
    create TABLE my_tab ( deptno VARCHAR2(5), job VARCHAR2(50), sal NUMBER);
    insert into my_tab ( deptno,JOB, sal) values ( 10, 'ANALYST', 23000);
    insert into my_tab ( deptno,JOB, sal) values ( 10, 'SALESMAN', 1500);
    insert into my_tab ( deptno,JOB, sal) values ( 10, 'CLERK', 3550);
    insert into my_tab ( deptno,JOB, sal) values ( 20, 'SALESMAN', 700);
    insert into my_tab ( deptno,JOB, sal) values ( 20, 'ANALYST', 4200);
    insert into my_tab ( deptno,JOB, sal) values ( 30, 'SALESMAN', 5600);
    insert into my_tab ( deptno,JOB, sal) values ( 30, 'CLERK', 12000);
    insert into my_tab ( deptno,JOB, sal) values ( 30, 'ANALYST', 19000);
    COMMIT;
    SELECT * FROM my_tab
    DEPTNO ______ JOB ________ SAL
    10 ______ ANALYST ________ 23000
    10 ______ SALESMAN     ________     1500
    10     _______ CLERK     ________     3550
    20     _______     SALESMAN ________     700
    20     _______     ANALYST     ________ 4200
    30     _______     SALESMAN ________     5600
    30     _______     CLERK     _______          12000
    30     _______ ANALYST     _______     19000
    --And I wish to convert it into this structure:
    DEPTNO ________ ANALYST ________ SALESMAN _________ CLERK
    10      ________     23000 ________     1500     _________     3550
    20     ________ 4200 ________     700     _________     NULL
    30     ________ 19000 ________     5600     _________     12000
    It may be dynamic. i.e Later i inserted more two records into My_tab.
    insert into my_tab ( deptno,JOB, sal) values ( 20, 'CLERK', 3400);
    insert into my_tab ( deptno,JOB, sal) values ( 30, 'MANAGER', 48000);
    So it should be dynamic.
    output is like this.
    DEPTNO ________ ANALYST ______ SALESMAN ______ CLERK ______ MANAMGER
    10           ________ 23000     ______ 1500     ______ 3550     ______     NULL
    20          ________ 4200     ______ 700     ______ 3400     ______     NULL
    30          ________ 19000     ______ 5600     ______ 12000     ______     48000
    Please help me regarding this.
    With warm regards,
    Prasanta

    Hi, Prasanta,
    Displaying one column from many rows as many columns on one row is called Pivoting . The following thread shows the basics of how to pivot:
    Help for a query to add columns
    That example uses the aggregate COUNT function; you'll want SUM (or possibly MIN or MAX) instead.
    Getting a dynamic number of columns requires Dynamic SQL . As a simpler alternative to pivoting and dynamic SQL, you might consider String Aggregation , where you concatenate a column from many rows into one big string, to be displayed on one row.
    See the following thread for more about string aggregation and other options on pivoting into a variable number of columns:
    Re: Report count and sum from many rows into many columns

  • Referring to Cursor Row and Column in Dynamic SQL

    I have a procedure that dynamically reads a schema name and table name from an input table. The code then needs to loop through all rows and columns of each table and output the data. I'm 95% done with what I want to accomplish, but there is one small bug. The line dbms_output.put(*col.column_name* || '',''); ' ||
    should refer to something like rec.col.column_name so that it gets the column of the current record. Right now it just displays the column name for each record instead of the actual value. Can anyone help me tweak the code to get the actual value?
    CREATE OR REPLACE PACKAGE BODY some_proc IS
    -- Function and procedure implementations
    PROCEDURE create_files IS
    CURSOR c_tbls IS
    SELECT * FROM tbl_list;
    l_sql VARCHAR2(4000);
    BEGIN
    --Loop through all tables
    FOR tbl IN c_tbls LOOP
    l_sql := 'DECLARE ' || ' CURSOR c_tbl_recs IS ' || ' SELECT * ' ||
    ' FROM ' || tbl.schema_name || '.' || tbl.table_name || '; ' ||
    ' t_tbl_rowtype c_tbl_recs%ROWTYPE; ' || 'BEGIN ' ||
    ' FOR rec IN c_tbl_recs LOOP ' ||
    ' FOR col IN (SELECT column_name ' ||
    ' FROM dba_tab_cols ' ||
    ' WHERE owner = ''' || tbl.schema_name || '''' ||
    ' AND table_name = ''' || tbl.table_name || '''' ||
    ' ORDER BY column_id) LOOP ' ||
    *' dbms_output.put(col.column_name || '',''); ' ||* ' END LOOP; dbms_output.put_line(''''); END LOOP; ' ||
    'END; ';
    --dbms_output.put_line(l_sql);
    EXECUTE IMMEDIATE l_sql;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line(SQLERRM);
    END;
    END;

    Is it this what you are looking for?
    (it took some minutes)
    create or replace
    package some_proc is
    procedure create_files;
    end;
    CREATE OR REPLACE
    PACKAGE BODY some_proc
    IS
      -- Function and procedure implementations
    PROCEDURE create_files
    IS
      CURSOR c_tbls
      IS
        SELECT * FROM tbl_list;
      CURSOR c_cols (p_table_owner VARCHAR2, p_table_name VARCHAR2)
      IS
        SELECT column_name
        FROM all_tab_columns
        WHERE owner   =p_table_owner
        AND table_name=p_table_name
        ORDER BY all_tab_columns.column_id;
      l_sql     VARCHAR2(32000);
      separator VARCHAR2(1):=';';
    BEGIN
      --Loop through all tables
      FOR tbl IN c_tbls
      LOOP
        dbms_output.put_line('TABLE: '||tbl.schema_name||'.'||tbl.table_name);
        l_sql := 'DECLARE ' ;
        l_sql := l_sql|| '  CURSOR c_tbl_recs IS ' ;
        l_sql := l_sql||'    SELECT * FROM ' || tbl.schema_name || '.' || tbl.table_name || '; ' ;
        l_sql := l_sql||'    linenr number:=1; ';
        l_sql := l_sql||'BEGIN ' ;
        l_sql := l_sql|| ' FOR rec IN c_tbl_recs LOOP ';
        FOR c IN c_cols(tbl.schema_name,tbl.table_name)
        LOOP
          l_sql:=l_sql ||' if linenr=1 then  dbms_output.put('''||c.column_name||''||separator||'''); end if; ' ;
        END LOOP;
        l_sql :=l_sql||'  dbms_output.put_line(''''); linenr:=linenr+1; ';
        FOR c IN c_cols(tbl.schema_name,tbl.table_name)
        LOOP
          l_sql:=l_sql ||' dbms_output.put(rec.'||c.column_name||'||'''||separator||'''); ' ;
        END LOOP;
        l_sql:=l_sql||'  end loop; ';
        l_sql:=l_sql||'  dbms_output.put_line(''''); ';
        l_sql:=l_sql||'  dbms_output.put_line(''''); ';
        l_sql:=l_sql||'end;';
        EXECUTE IMMEDIATE l_sql;
      END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line(SQLERRM);
    END;
    END;
    /

  • How to use the column names generated from Dynamic SQL

    Hi,
    I have a problem with Dynamic SQL.
    I have written an SQL which will dynamically generate the Select statement with from and where clause in it.
    But that select statement when executed will get me hundreds of rows and i want to insert each row separately into one more table.
    For that i have used a ref cursor to open and insert the table.
    In the select list the column names will also be as follows: COLUMN1, COLUMN2, COLUMN3,....COLUMNn
    Please find below the sample code:
    TYPE ref_csr IS REF CURSOR;
    insert_csr ref_csr;
    v_select VARCHAR2 (4000) := NULL;
    v_table VARCHAR2 (4000) := NULL;
    v_where VARCHAR2 (4000) := NULL;
    v_ins_tab VARCHAR2 (4000) := NULL;
    v_insert VARCHAR2 (4000) := NULL;
    v_ins_query VARCHAR2 (4000) := NULL;
    OPEN insert_csr FOR CASE
    WHEN v_where IS NOT NULL
    THEN 'SELECT '
    || v_select
    || ' FROM '
    || v_table
    || v_where
    || ';'
    ELSE 'SELECT ' || v_select || ' FROM ' || v_table || ';'
    END;
    LOOP
    v_ins_query :=
    'INSERT INTO '
    || v_ins_tab
    || '('
    || v_insert
    || ') VALUES ('
    || How to fetch the column names here
    || ');';
    EXECUTE IMMEDIATE v_ins_query;
    END LOOP;
    Please help me out with the above problem.
    Edited by: kumar0828 on Feb 7, 2013 10:40 PM
    Edited by: kumar0828 on Feb 7, 2013 10:42 PM

    >
    I Built the statement as required but i need the column list because the first column value of each row should be inserted into one more table.
    So i was asking how to fetch the column list in a ref cursor so that value can be inserted in one more table.
    >
    Then add a RETURNING INTO clause to the query to have Oracle return the first column values into a collection.
    See the PL/SQL Language doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/returninginto_clause.htm#sthref2307

  • Dynamic SQL Query to Find Special Characters in Table columns

    Hi,
    I am new to OTN FORUMS.
    I am trying to find the columnsi of a table which have special characters in them.
    I am planning on using this query
    select ' select INSTR('||column_name||', chr(0))
    from '||table_name||'where INSTR('||column_name||', chr(0)) >0' from user_tab_columns
    where table_name='Account'
    and spool the output to run as a script.
    Is this the right way or do u suggest any modifications to the query?
    Thanks in advance.

    Hi,
    I think your basic approach is right. Since you can't hard-code the table- or column names into the query, you'll need dynamic SQL.
    Instead SQL-from-SQL (that is, writing a pure SQL query, whose output is SQL code), you could do the whole job in PL/SQL, but I don't see any huge advantage either way.
    When you say "Special character<b>s</b>", do you really mean "one given special character" (in this case, CHR(0))?
    Will you ever want to search for multiple special characters at once?
    What if table foo has a column bar, and in 1000 rows of foo, bar contains CHR (0). Do you want 1000 rows of output, each showing the exact position of the first CHR(0)? If the purpose is to look at theese rows later, shouldn't you include the primary key in the output? What if CHR(0) occurs 2 or more times in the same string?
    If you'd rather have one row of output, that simply says that the column foo.bar sometimes contains a CHR(0), then you could do something like this:
    SELECT     'foo',     'bar'
    FROM     dual
    WHERE     EXISTS (
                SELECT  NULL
                FROM       foo
                WHERE       INSTR ( bar
                            , CHR (0)
                        ) > 0
                );

  • Converting rows to columns using dynamic query.

    I am trying to use the below code that I founnd on the web to conver rows to columns. the reason that I want to use dynamic query is that the number of rows are not know and changes.
    declare
        lv_sql varchar2(32767) := null ;
    begin
        lv_sql := 'SELECT Iplineno ';
        for lv_rec in (SELECT distinct vendor from bidtabs  where letting = '10021200' and call ='021')
        loop
            lv_sql :=   lv_sql
                        || CHR(10)
                        || ', MAX( DECODE( vendor, '
                        || chr(39)
                        || lv_rec.vendor
                        || CHR(39)
                        || ', bidprice, NULL ) ) as "'
                        || lv_rec.vendor
                        || '" ' ;
        end loop;
        lv_sql :=   lv_sql
                    || CHR(10)
                    || 'FROM bidtabs  where letting =  ''10021200''  and call =  ''021''  and lineflag = ''L''  '
                    || CHR(10)
                    || 'GROUP BY iplineno ;' ;
    here is the result
    BIDPRICE     CALL     IPLINENO     LETTING     VENDOR
    9,585     021     0010     10021200     C0104        
    1,000     021     0020     10021200     C0104        
    1,000     021     0030     10021200     C0104        
    17     021     0040     10021200     C0104        
    5     021     0050     10021200     C0104        
    11,420     021     0010     10021200     K0054        
    1,100     021     0020     10021200     K0054        
    1,100     021     0030     10021200     K0054        
    5     021     0040     10021200     K0054        
    3     021     0050     10021200     K0054        
    8,010     021     0010     10021200     V070         
    900     021     0020     10021200     V070         
    1,320     021     0030     10021200     V070         
    11     021     0040     10021200     V070         
    3     021     0050     10021200     V070         
    and here is the desired output
    CALL     IPLINENO     LETTING      C0104              K0054              V070         
    021     0010     10021200      9,585                     11,420                                   8,010
    021     0020     10021200      1,000       1,100     900
    021     0030     10021200      1,000     1,100     1,320
    021     0040     10021200       17     5     11
    021     0050     10021200      5     3     3

    Here is the error message I am getting:
    RA-06550: line 22, column 43:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-identifier>
    <a bind variable> << close current delete fetch lock insert
    open rollback savepoint set sql execute commit forall merge
    pipe

  • Rows to Columns within PL/SQL or sql.

    Hi i need to get this data which is being extracted using a sql query with a prior by clause and is being displayed as rows. to display as seperate column on one row., the values need to be in their own column on the same row...
    table layout
    Level 1   Level2     Level3    Level4    Level5 
    column1     column2     column3
    270767     197851            1
    64631     230693            2
    33115     230481            3
    229148     209655            4
    So i need to get these rows into the columns on the table........ But the rows can go upto 11 and beyond so i will create a table with lots of columns, but for now
    just using 5 , But i want the script so it can just keep going through the columns not just restricted to 5....

    Hi,
    Use SYS_CONNECT_BY_PATH to get a delimited list of all the values, in order by LEVEL.
    I would just display that: you don't have to know how many LEVELs there might be, and therefore how many columns you have to hard-code into the query.
    If you really do have to split the list into separate columns, use
    REGEXP_SUBSTR ( sys_connect_by_path_results
                  , '[^,]+'    -- where , is the delimiter: any other single character would do as well
                  , 1
                  , n
                  )to get the n-th item on the list. You have to hard-code the worst case (the maximum number of levels), or use dynamic SQL to do it for you.
    For a more specific answer, post a more specific question.
    Include:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data
    (4) Your best attempt so far (formatted)
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    If you can present your problem using commonly available tables (for example, tables in scott schema, where emp has a nice hierarchy), then you can omit (2).
    Formatted tabular output is okay for (3). Type these 6 characters
    (small letters only, inside curly brackets) before and after formatted, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • How to get inputted value in a RTE field on custom page and submit by REST call in 'Sharepoint hosted app'.

    Hi I am facing the three questions below. 1. How to use default RTE in custom page in Sharepoint hosted app.  I saw the article of Rich text Editor (ribbon based) in a webpart in SharePoint 2013 and tried it. But it did not work well. I guess it need

  • Screen flicker for Mac Mini

    I got the Mac Mini for about one week. When I connect it to my LG W1952TQ monitor, the monitor become flicker.  I have to turn the monitor off for several times and wait for the Mac mini to warm up before the monitor screen improved. Did anyone got a

  • How send Email of PO for approval from EBS 11i?

    HI, We are currently sending PO approvals through emails in Oracle EBS 11i (11.5.10.2). When our users are approving PO from their laptops and desktop using Outlook everything is OK. But when the same emails are received on Mobile phones we are facin

  • Protege M600 Sound Problem

    Protege M600 Sound ProblemI have reinstall my laptop to windows Xp Sp3, I have try to install sound driver and warning message show: "Cannot Access Volume Control" Could you help me to solve this problem. OS: windows XP sp3 Toshiba Portege M600 Model

  • Creating a key for a Time table in HMM format

    Hello, I am looking to create an INT column in SQL that inserts all hours and minutes within a day (that is, 1440 entries), in the following format: HMM Where: H is the 24 hours format, without that leading zero, and MM are the minuts with the leadin