Get comma SQL query result

Hey everybody

I have a requirement where I need to get result separated by commas to names because there are many relationships that is, for each protocol, there are mutiple people linked to it, and I created the PL/SQL function for this and everything was going well and when he is in the production of several cursors have been opened due to the logic and leading to CARS more and for that we have summer manually clear cursors every weekend and I'm you're looking to create a view, materialized for this logic but I was unable to encode the logic by using Connect by clause

The result is like and I want the names separated by commas for each protocol
P06065 TESTER13 TESTER13
P02095 PATRICIA CARMELITANO
P02095 ANNE MUIR
P02095 ROBERT HARLOW
P02095 JANICE ALBERT
P02095 Jacqueline van Dalen
P02095 DR. GUENTER HENNIG.
P05209 Olga Xenaki
P05553 Birgit Limbach-Angele
P05553 Anja Dr. Schulz.
P05553 CHRISTA HAGENBUCHER

Here's the function I wrote, I need to get the same logic through the SQL statement... Thanks for your help

cursor c_GSCR is
Select T565804. FST_NAME | » '|| T565804. LAST_NAME
Of
S_PT_POS_HST_LS T544105 / * S_PT_POS_HST_LS_Protocol_Team * /,.
S_CONTACT T565804 / * S_CONTACT_Protocol_Team * /,.
S_CL_PTCL_LS T541903 / * S_CL_PTCL_LS_Protocol * /.
where (T541903. ROW_ID = T544105. CL_PTCL_ID and
T544105. POSTN_ID = T565804. PR_HELD_POSTN_ID and
T544105. ROLE_CD = 'Lead project manager' AND
T541903. ROW_ID = v_PTCL_ID and
T541903. PAR_PTCL_ID is set to null, and T544105. END_DT is null);

BEGIN
l_row_num: = 0;
l_role: = ";
l_role_list: = ";
v_PTCL_ID: = PTCL_ID;

C_GSCR OPEN;
If C_GSCR % isopen THEN
LOOP
FETCH C_GSCR INTO l_role;
When the output C_GSCR % notfound;

IF l_role_list IS NULL THEN
l_role_list: = l_role;
ON THE OTHER
l_role_list: = l_role_list | ',' | l_role;
END IF;

END LOOP;
CLOSE C_GSCR;
end if;

~ Srix

Hello

You can try something like this:

select loan_code, rtrim(xmlagg(xmlelement(e,loan_tran_code||',').extract('//text()')),',')  as loan_tran_codes
from  st_lo_trans
where st_code  = 24
group by loan_code

Tags: Database

Similar Questions

  • How to get the sql query result?

    Hello

    Currently I use LV2012 to connect to an Oracle database server. After the Oracle Express and Oracle ODBC driver facilities/settings made.

    I managed to use the SQL command to query the data through my command prompt window.

    Now the problem is, how to do the same task in Labview using database connectivity tools?

    I have build a VI to query as being attached, but I have no idea of what range to use to get the result of the query.

    Please help me ~ ~

    Here is a piece of code that I use to test the SQL commands, you can use the part that retrieves the results of sql.

    It is also possible to get the rear column headers, but it's for the next lesson!

    ;-)

  • How to get the SQL query running of af: search?

    I use JDeveloper 11.1.2.3.0. I have a page where I've set up an af:query and an array of result. The problem is that I can't get the exact query that is used during the execution of this component in a managed bean method. Is it possible to get the query string that is run within the af: query?

    Thank you

    Hello

    Method of the ViewObject getQuery() returns what you need;

    You can replace the executeQueryForCollection(), and prior to calling super, you can print the result of getQuery() method:

    public void executeQueryForCollection (rowset Object,

    Object [] params,

    {int noUserParams)

    System.out.println ("SQL =" + getQuery());

    call the super method here...

    }

  • The SQL query result

    Hello

    Here's my data in the table for itm_id = 1000

    ITM_IDADD_ATRDEL_ATR
    1000a: b:c:d
    1000d
    1000d
    1000e:f:g
    1000e:f:g

    My required return is (a: b:c:d) d = a: b: c + d = a: = a +(e:f:g) b:c:d: b:c:d:e:f:g-(e:f:g) = a: b: c; d

    Output ITM_ID

    1000A: b:c:d

    can we get the output using the sql query above?

    I had tried with union but could not able to get the required result.

    Please let me know if there is no possible solution

    Thank you

    David

    I have the impression that you are looking to treat each character in 'RTA' as an individual item and then add or delete depending on whether they are an ADD_ATR or DEL_ATR.

    So something like...

    SQL > ed
    A written file afiedt.buf

    1 with t as (select 1000 as itm_id, ' a: b/c: some like add_atr, null as del_atr of all the double union)
    2 select 1000, null, would be "union double all the"
    3 select 1000, 'd', null of union double all the
    4 select 1000, 'e:f:g', null of union double all the
    5 select 1000, null, "e:f:g" of all the double union
    6 select 1234, null, "x: y: z" of all the double union
    7 select 1234, 'u: v: w', null of union double all the
    8 select 1234, null, 'u' of all the double union
    9 select 1234, "x: y", null of union double all the
    10. Select 1234, "x: z", null of union double all the
    11. Select 1234, 'p', the double null
    12            )
    13-
    14. end of test data
    15-
    16. Select itm_id
    17, cast (listagg(atr,':') within the Group (order by atr) as varchar2 (40)) output
    18 of)
    19 select itm_id
    20, atr
    21, sum (add_del)
    22 of)
    23 select itm_id
    24, coalesce(add_atr,del_atr) as full_atr
    25, decode (add_atr, null,-1, 1) as add_del
    26, regexp_substr (coalesce(add_atr,del_atr),'[^:] +', 1, level) RTA
    27, flat surface that l
    28 t
    29 to connect by level<= (length(coalesce(add_atr,del_atr)="">
    30 and itm_id = prior itm_id
    31 and coalesce(add_atr,del_atr) = prior coalesce(add_atr,del_atr)
    sys_guid() 32 and prior is not null
    33             )
    34 group by itm_id, atr
    35 having sum (add_del) > 0
    36       )
    37 * group by itm_id
    SQL > /.

    ITM_ID OUTPUT
    ---------- ----------------------------------------
    1000A: b:c:d
    1234 p:v:w:x

    that just shows how stupidly data is as it should be divided every thing in the different elements so that you can then group to determine how many of each, you have (and whether to add or subtract) and then re - combine results again in a combined string.

  • How do I get recommendations sql query manually, its possible or not?

    I'm new dba oracle and my company gives me sql optimize, if research on google and knowledge, addm can give recommendations of sql query

    but I sql query and in addm can not give recommendations,

    I then how sql query performance increase... ?

    and the sql script to get the recommendations?

    Thanks in advance

    1. upgrade to oracle 11

    2. (take the topgun)

    Select / * + RESULT_CACHE * / a.empid, empname from

    (select empid, empname from india_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from us_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from uk_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from uae_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from brazl_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from chine_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from jpn_emp

    where deptno in (54,256,362,9879,24,46) and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    ) a

    order by 2;

    3. run the query 3 times.

    The query will be lightning fast from the 3rd time

    4. read the full performance tuning guide

    http://docs.Oracle.com/CD/E11882_01/server.112/e41573/TOC.htm

  • the SQL query result format

    Format the results of the SQL query, currently, show as below.

    Select license_type, correspondents of license_info where license_type in ('TEM', 'TDM') order by license_type;

    TDM 1445140800000000000
    TDM 1420952400000000000
    TDM 1444363200000000000
    TDM 1445054400000000000
    TDM 1428724800000000000
    TEM 1421125200000000000
    TEM 1423890000000000000
    TEM 1449637200000000000
    TEM 1444968000000000000
    TEM 1428724800000000000

    I need formatting like below

    Expected result:

    TDM 1445140800000000000 TEM 1421125200000000000
    TDM 1420952400000000000 TEM 1423890000000000000
    TDM 1444363200000000000 TEM 1449637200000000000
    TDM 1445054400000000000 TEM 1444968000000000000
    TDM 1428724800000000000 TEM 1428724800000000000

    I have sample data only, Blue said the change in your main table request

    Try:

    Select max (f1),

    Max (F2),

    Max (F3),

    Max (F4)

    de)

    Select decode (license_type, 'TDM' license_type) f1,

    Decode (license_type, 'TDM', expiration_date) f2,

    Decode (license_type, 'TEM' license_type) f3,

    Decode (license_type, 'TEM', expiration_date) f4,

    ROW_NUMBER() over (partition by order correspondents license_type) r

    Of

    )

    R group

    ----

    Ramin Hashimzade

  • Failed to 150 000 lines extracted from "xlsx" SQL query results

    Environment:

    SQL * Developer 3.1.07.42 on Windows XP SP3
    Oracle 11.2.0.3 EE on Solaris 10.5

    I ran a query in a spreadsheet window and the first page of results came back in 10 seconds, whoo hooo!

    I right click on the first column of the first row and selected 'Rows Count' and back 527 563 after thinking a bit.

    I clicked 'Export', selected a box for "Query worksheet name" "xlsx", uncontrolled size and traveled to specify the output file directory (my local C: drive) and the name of the file. I clicked on "Next" and then on "Finish".

    I watch the meter of the line at the bottom right of the window and it went very quickly until he hit about 150 000 lines and then it started to slow down. It got slower and slower and slower and slower, and you get the picture, and finally, I killed the process when it took more than 15 seconds from 156 to 156 250 245.

    Why would it be?

    Additional information:

    I have the same exact query is represented and exported the same lines 527 563 using the "xls" instead of "xlsx" format and the process has proceeded all the way to the end very quickly and successfully completed in just a few minutes. The worksheet resulting contained 8 eight worksheets since it could only put 65536 lines on each worksheet. This was acceptable to the user who just merged the data manually.

    There are some issues with the help of "xlsx" format of output as opposed to simply use it as input format?

    Is SQL * Developer trying to create a spreadsheet with the same number of rows as the data up to the max in Excel 2010 (over 527 563)?

    Thanks a lot for all shed light on this issue. If I omitted no details important please let me know and I'll try to include them.

    -gary

    Hi gary,.

    You may have seen one or more threads as follows on the question of fees increased memory overhead for the formats of Excel:
    Re: Developer Sql 3.1 - export a set of results in xls generates and empty the file

    Basically, Developer SQL uses a third-party provider API to read and write these Excel formats. There are separate readers and trainers for each of the forms xls and xlsx.

    There is a new version of the API that supports streaming of xlsx workbooks. Basically, he made a much lower footprint bearing in mind that the lines which are in a sliding window, while that older, without flow version gives access to all lines in the document. The programmer can define the size of this window. In my view, that the most recent version of the API was not available or is not stable during our cycle 3.1 development. Perhaps a future version of SQL Developer can use it.

    Kind regards
    Gary
    SQL development team

  • Reruns of data to export the SQL query results grid

    I am running SQL Developer 2.1 on Windows XP. I have a long query that returns the results to the DataGrid. When I export these results, the query is executed again. Why? Is it possible to export the results without rerunning SQL?

    Should not happen. But when sqldev returns results, mind that he gets only the first 50 lines. If you do not get them all before you export, they must be obtained at the course.
    Try CTRL-END in result grid before export and see if it works.

    Hope that helps,
    K.

  • Worksheet hide hotkey SQL query result window?

    I am new to the use of SQL Developer (version 2.1) and am unable to find a keyboard shortcut or shortcut key that allows me to show/hide the results of the query tab. I guess its possible, I'm wrong?

    Thanks for the help!

    PJ

    Have the focus on the results of the worksheet tab.
    Press F8.
    Use Home/End or the up/down arrow key to move the separator.

    -Rambeau

  • How do I get this sql query?

    Hi all

    I'm using oracle 11g.

    I have a table as below:

    [code] create table id_test)

    Identification number, name varchar2 (20)

    ) ;

    [/ code]

    And records like below:

    [code]

    ID NAME

    1 sr

    1 ds

    2 sr

    DS 2

    3 sr

    [/ code]

    where I want to select only the id that have only the name as "sr."

    But as I have 100 names cannot put a not in condition to check other names.

    The expected result would be like:

    [code]

    ID NAME

    3 sr

    [/ code]

    Concerning

    Dale

    Do you want to max (id) name = "SR"... Try the below

    SELECT id,

    name

    GO (select id,

    name,

    ROW_NUMBER() over (ORDER BY id desc) rn

    of id_test

    WHERE name = 'sr')

    WHERE rn = 1

    OR

    SELECT MAX id (id),

    name

    Of id_test

    WHERE name = 'sr '.

    GROUP BY name.

    OR if you want to get the id which is only in SR, then try it out below

    SELECT id,

    name

    Id_test A1

    WHERE name = 'sr '.

    AND NOT EXISTS (SELECT 1 from id_test a2

    WHERE a1.id = a2.id

    AND name! = « sr ») ;

    Post edited by: 000000

  • How to get the sql query

    Hello

    I already set date value as below.
    SET THE VALUE OF START_TIME = 2011-08-12 09:00
    DEFINE END_TIME = 2011-08-12 10:00
    and executes the table based on the defined date as below,
    Select * from my_table
    where
    (to_date (Accounting_Start_Time,'yyyy-mm-dd HH24:MI:SS) > = to_date ('& start_time ',' yyyy-mm-dd HH24:MI:SS) and to_date (Accounting_Stop_Time,'yyyy-mm-dd HH24:MI:SS) < = to_date ('& end_time ',' yyyy-mm-dd HH24:MI:SS))
    GOLD to_date (Accounting_Start_Time,'yyyy-mm-dd HH24:MI:SS) > = to_date ('& start_time ',' yyyy-mm-dd HH24:MI:SS) and to_date (Accounting_Stop_Time,'yyyy-mm-dd HH24:MI:SS) > = to_date ('& end_time ',' yyyy-mm-dd HH24:MI:SS) and to_date (Accounting_Start_Time,'yyyy-mm-dd HH24:MI:SS) < = to_date ('& end_time ',' yyyy-mm-dd HH24:MI:SS)
    GOLD to_date (Accounting_Start_Time,'yyyy-mm-dd HH24:MI:SS) < = to_date ('& start_time ',' yyyy-mm-dd HH24:MI:SS) and to_date (Accounting_Stop_Time,'yyyy-mm-dd HH24:MI:SS) < = to_date ('& end_time ',' yyyy-mm-dd HH24:MI:SS) and to_date (Accounting_Stop_Time,'yyyy-mm-dd HH24:MI:SS) > = to_date ('& start_time ',' yyyy-mm-dd HH24:MI:SS)
    GOLD to_date (Accounting_Start_Time,'yyyy-mm-dd HH24:MI:SS) < = to_date ('& start_time ',' yyyy-mm-dd HH24:MI:SS) and to_date (Accounting_Stop_Time,'yyyy-mm-dd HH24:MI:SS) > = to_date ('& end_time ',' yyyy-mm-dd HH24:MI:SS));
    ) but now I want to query the table based on the time,

    Any help please,.

    Hello

    It is not very hard in SQL * more.

    First of all, put your query in a script file, like this one, called hour_query.sql:

    --     hour_query.sql          Show data from my_table for a given time period
    
    PROMPT     The data below shows the period from &1 to &2
    PROMPT
    
    SELECT     *
    FROM     my_table
    WHERE     accounting_start_time     <= '&2'
    AND     '&1'               <= accounting_stop_time
    ;
    

    Parameters & 1 and & 2 are beginning and end of time, for example "2011-08-12 09:00".
    Note that this does not use TO_DATE. If you have incorrect strings in columns that must be DATEs, no errors occur.

    Assuming that hour_query.sql is located on p:\some_dir\, you want another script that runs hour_query.sql 24 times, like this one, which I will call all_hours.sql:

    @p:\some_dir\hour_query  "2011-08-12 09:00:00"  "2011-08-12 10:00:00"
    @p:\some_dir\hour_query  "2011-08-12 10:00:00"  "2011-08-12 11:00:00"
    @p:\some_dir\hour_query  "2011-08-12 11:00:00"  "2011-08-12 12:00:00"
    ...
    

    (I just did 3 hours to test. You can easily make that 24 hours).

    The following code creates and then runs all_hours.sql:

    -- Turn off SQL*Plus features that interfere with raw output
    SET     FEEDBACK     OFF
    SET     PAGESIZE     0
    SET     VERIFY          OFF
    
    -- Write all_hours.sql
    SPOOL     p:\&some_dir\all_hours.sql
    
    WITH     got_start_time     AS
    (
         SELECT TO_DATE ( '2011-08-12 09:00:00'
                            , 'YYYY-MM-DD HH24:MI:SS'
                     ) AS start_time
         FROM    dual
    )
    SELECT     '@p:\some_dir\hour_query  "'
        ||  TO_CHAR ( start_time + ((LEVEL - 1) / 24)
              , 'YYYY-MM-DD HH24:MI:SS'
              )
        ||  '"  "'
        ||  TO_CHAR ( start_time + ( LEVEL      / 24)
              , 'YYYY-MM-DD HH24:MI:SS'
              )
        ||  '"'
    FROM    got_start_time
    CONNECT BY     LEVEL <= 3     -- You can make this 24, or any other number
    ;
    
    SPOOL     OFF
    
    -- Turn on SQL*Plus features turned off earlier
    SET     FEEDBACK     ON
    SET     PAGESIZE     50
    -- Except VERIFY.  leave that OFF while all_hours runs
    --SET     VERIFY          OFF
    
    -- Run all_hours.sql
    @p:\some_dir\all_hours.sql
    
    SET     VERIFY     ON
    
  • Report Null VS discoverer view show SQL query results.

    I created a simple Cross Tab discoverer of a custom SQL report that has a calculation for sales. The output is to give all null values even if there is a sale. The output does not seem fair. Then I copied the query from tools-> SQL Show and ran the query in the TOAD where I show the balances for the report. I don't understand why it does not show in the discoverer. Help, please.


    Thank you

    Published by: PA1B on January 27, 2010 11:40

    Hello

    You must show the translated_flag as a dimension in the report or use it in a function group in the calculation. What calculation should be tried? And why did not work?

    Rod West

  • Get a SQL query to view already created

    Hello

    I have a vision that is created along back and tables related to the display has changed. I just wanted to check the query by which the view was created. How can I find/recover the written request for this point of view?


    Thank you...

    Hello!

    Sounds good, but please mark the thread as answered and please give me the rewardpoints for the correct answers.

    concerning

  • Components catalog SQL query and caching

    Hello

    It seems that SQL query result sets components catalog caching and go to the DB only after restarting the engine. Is it possible to disable this caching and force SQL queries to run each time?

    Thank you.
    Nick.

    Hi Nick,

    Take a look at the log file of your engine. To execute SQL queries when running logic. See if you get any 'error', 'Serious' or 'Warning' engine log messages when you run your query.

    Hope this helps,
    Dan

  • Need help to build the query/pl-sql block to get the query result and the name of column from DB table in the form of key-value pairs.

    Hi Experts,

    I have a DB table has columns of more than 50.

    I question this table, it should only return one line at any time. as sqldeveloper below image.

    here, I need to build block pl/sql-query, Discover the column in the table as a key and query result as values.

    Eg:     Key                         -  Value

    TASK_EVENT_ID - 1765

    EVENT_TYPE - ASR_UPDATE

    ... etc until all of the columns in my table.

    Experts please comment on that point, appreciate your help on this.

    Thank you

    -Vincent.

    Here is an approach using DBMS_SQL to iterate over the columns of key / value to assign... (Little code snipped for brevity)

    create or replace procedure (task_expired)

    v_store_id in full,

    v_task_action_id in full,

    v_job_id in full

    )

    as

    -[SNIP code...]

    v_sql VARCHAR2 (4000): = ' select * from my_table where PK = 123';  -Your SQL here!

    v_v_val VARCHAR2 (4000);

    v_n_val NUMBER;

    v_d_val DATE;

    v_ret NUMBER;

    c NUMBER;

    d NUMBER;

    col_cnt INTEGER.

    f BOOLEAN;

    rec_tab DBMS_SQL. DESC_TAB;

    col_num NUMBER;

    vAsString VARCHAR2 (4000);

    BEGIN

    -[SNIP code...]

    Message_properties. CORRELATION: = "EDF_EVENT";

    MSG: = SYS. AQ$ _JMS_BYTES_MESSAGE. Construct();

    Msg.set_string_property ('queueName', ' shipping/csi_cth');

    Msg.set_string_property ('MODE', 'CR8');

    c: = DBMS_SQL. OPEN_CURSOR;

    DBMS_SQL. PARSE (c, v_sql, DBMS_SQL. NATIVE);

    d: = DBMS_SQL. Execute (c);

    DBMS_SQL. DESCRIBE_COLUMNS (c, col_cnt, rec_tab);

    1.col_cnt J

    LOOP

    CASE rec_tab (j) .col_type

    WHEN 2 THEN

    DBMS_SQL. DEFINE_COLUMN (c, j, v_n_val);      -Number

    WHEN 12 CAN

    DBMS_SQL. DEFINE_COLUMN (c, j, v_d_val);      -Date

    ON THE OTHER

    DBMS_SQL. DEFINE_COLUMN (c, j, v_v_val, 2000);   -Else treat as varchar2

    END CASE;

    END LOOP;

    LOOP

    v_ret: = DBMS_SQL. FETCH_ROWS (c);

    WHEN OUTPUT v_ret = 0;

    1.col_cnt J

    LOOP

    -Fetch each column to the correct data type based on coltype

    CASE rec_tab (j) .col_type

    WHEN 2 THEN

    DBMS_SQL. COLUMN_VALUE (c, j, v_n_val);

    vAsString: = to_char (v_n_val);

    WHEN 12 CAN

    DBMS_SQL. COLUMN_VALUE (c, j, v_d_val);

    vAsString: = to_char (v_d_val, ' DD/MM/YYYY HH24:MI:SS');

    ON THE OTHER

    DBMS_SQL. COLUMN_VALUE (c, j, v_v_val);

    vAsString: = v_v_val;

    END CASE;

    Msg.set_string_property (rec_tab (j) .col_name, vAsString);

    END LOOP;

    END LOOP;

    DBMS_SQL. CLOSE_CURSOR (c);

    DBMS_AQ. ENQUEUE (queue_name-online 'cbus.aqjms_common',

    Enqueue_options => Enqueue_options,

    Message_properties => Message_properties,

    Payload-online msg,

    Msgid => Message_handle);

    dbms_output.put_line ('00 Msgid =' |) Message_handle);

    dbms_output.put_line('===Done=');

    -[SNIP code...]

    END;

    /

Maybe you are looking for