WM_concat
Hi all
I have a sample of data and I have provided the scripts below.
create the table test_data
(deptcode varchar2 (10), hid number, number of applevel, approver_employee varchar2 (10))
Insert into test_data
values ('051 ', 1,1,'1487 ');
Insert into test_data
values ('051 ', 1,2,'8806 ');
Insert into test_data
values ('051 ', 1,3,'9038 ');
Insert into test_data
values ('051 ', 2,1,'5167 ');
Insert into test_data
values ('051 ', 2.2,'8806 ');
Insert into test_data
values ('051 ', 2,3,'9038 ');
Insert into test_data
values ('051 ', 3,1,'5375 ');
Insert into test_data
values ('051 ', 3.2,'8806 ');
Insert into test_data
values ('051 ', 3.3,'9038 ');
Insert into test_data
values ('051 ', 1,'4367 ');
Insert into test_data
values ('051 ', 4.2,'8806 ');
Insert into test_data
values ('051 ', 4.3,'9038 ');
but when I run the following query
Select deptcode, hidden, wm_concat (applevel) wm
of test_data
Deptcode, hidden group
hidden agenda
HIDDEN WM DEPTCODE
----------------------------
051 1 1,2,3
051 2 1,2,3
051 3 1,3,2
051 4 1,2,3
the third line should also be 1,2,3
I need result in the following format
hidden deptcode applevel
1 051 1,2,3
2 051 1,2,3
3 051 1,2,3
4 051 1,2,3
Please notify
WM_CONCATE is undocumented and do not use undocumented features. They may not be available in future versions, or they could change. And we do not know what exactly they intend to do.
Try this
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> select deptcode, hid, ltrim(sys_connect_by_path(applevel, ','), ',') applevel 2 from test_data 3 where connect_by_isleaf = 1 4 start with applevel = 1 5 connect by applevel = prior applevel + 1 6 and prior deptcode = deptcode 7 and prior hid = hid; DEPTCODE HID APPLEVEL ---------- ---------- ---------- 051 1 1,2,3 051 2 1,2,3 051 3 1,2,3 051 4 1,2,3
Tags: Database
Similar Questions
-
How can'i use wm_concat in ODI 10
Hello
I would like to know how to use the wm_concat function in an ODI interface (I use 10 ODI)
For example, I have the following source data
A B C
--- --- -------
20 5 SMITH
30 3 ALLEN
30 2 WARD
20 4 JONES
30 2 MARTIN
30 3 BLAKE
10 1 CLARK
20 3 SCOTT
10 3 KING
30 5 TURNER
20 2 ADAMS
30 5 JAMES
20 1 FORD
10 5 MILLER
and I want to insert the next data kes
A sum(B) wm_concat(c)
--- --- ------------------------
10 9 CLARK,KING,MILLER
20 15 SMITH,FORD,ADAMS,SCOTT,JONES
30 20 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD
by adding a function of sum () in the column mapping B.
The following query generates the ODI
SELECT A, SUM (B), WM_CONCAT (C) FROM <table> GROUP BY A, WM_CONCAT (C);
This means that the ODI does not recognize WM_CONCAT as aggregate function.
don't you think that it is possible to say ODI to do not function in the group by
PS: I use an Oracle 11 g database 2 which recognizes the WM_CONCAT function.
Thank you very much
Hello
WM_Concat is no longer valid, that it has been deprecated by oracle, a long time ago.
Using the LISTAGG function instead... It should work in ODI...
SELECT deptno, LISTAGG (ename, ',') INTRA GROUP (ORDER BY ename) as employees
WCP
GROUP BY deptno;
DEPTNO EMPLOYEES
---------- --------------------------------------------------
10 CLARK, KING, MILLER
ADAMS, FORD, JONES 20, SCOTT, SMITH
ALLEN, JAMES, MARTIN, BLAKE, TURNER, WARD 30
If this solves your problem... close the thread...
Thank you
ASP.
-
Reg: WMSYS. WM_CONCAT or LISTAGG
All,
I'm trying to select column names that begin with "E" in my sql query projection area. For this I used USER_TAB_COLS with WMSYS. WM_CONCAT / LISTAGG too.
I got the names of columns, with separator ", but could not inject it to the sql query. Please help me.
SQL > SELECT WMSYS. WM_CONCAT (column_name)
2 FROM user_tab_cols
3 WHERE table_name = 'EMP '.
4 AND column_name LIKE '% E ';WMSYS. WM_CONCAT (COLUMN_NAME)
--------------------------------------------------------------------------------
EMPNO, ENAMESQL > SELECT
2. (SELECT WMSYS. WM_CONCAT (column_name)
3 FROM user_tab_cols
4 WHERE table_name = 'EMP '.
5 AND COLUMN_NAME LIKE '% E '.
(6) a
7 FROM EMP where rownum < = 4;A
--------------------------------------------------------------------------------
EMPNO, ENAME
ERROR:
ORA-22922: non-existent LOB value-LISTAGG
SQL > select (selection ListAgg (column_name, ',')
2 IN THE GROUP (ORDER BY COLUMN_NAME DESC) AS CONCATV
3 to user_tab_cols
4. WHERE TABLE_NAME = 'EMP '.
5 AND COLUMN_NAME LIKE '% E') a FROM EMP WHERE ROWNUM < = 3;A
----------------------------------------------------------------------------------------------------
ENAME, EMPNO
ENAME, EMPNO
ENAME, EMPNOThank you
Here is an example of what you want to do:
: c is of type cursor
declare
v varchar2 (4000);
Start
Select GROUP(ORDER BY COLUMN_NAME DESC) AS CONCATV ListAgg (column_name, ',')
v
of user_tab_cols
WHERE TABLE_NAME = 'MYTABLE ';
Open: c for 'select'. v. "from MYTABLE";
end;
----
Ramin Hashimzade
-
lines due to the wm_concat() in double request gorge yourself
Here's the query I need to run
SELECT the separate user interface. Index_name, UI. Owner, UI. Table_name, wm_concat (uic.column_name) on column_name (partition by order of position_colonne uic.index_name), the ui.index_type, the parameters
Of
all_IND_COLUMNS UI all_INDEXES JOIN UIC
ON UIC. INDEX_NAME = UI. INDEX_NAME
where
SUBSTR (UI.index_name, 1, 3) not IN ("PK_", 'UQ_', ' DR$ ")
and ui.index_name not like 'SYS_C00% '.
and ui.index_name not like 'SYS_IOT_TOP_ %' and owner = 'USER1 '.
control of the user interface. INDEX_NAME
The problem is wm_concat() because the all_IND_COLUMNS table contains the entry duplicated for index (index1 of the table(column1,column2,column3) type)
for this wm_concat returns the result as below:
--------------------
Column1
Column1, Column2
Column1, Column2, Column3
But in * result I don't need it for a particular name of index (separate index)
as an example, I have two indexes in schema:
index1 on table1 (column1, column2, column3) and
Index2 on table2 (column5)
This result need
Row1 - index1 Column1, Column2, Column3
Index2 column 5 row2-
my query returns
index1 Column1 row1-
row2 - index1 Column1, Column2
row3 - index1 Column1, Column2, Column3
row4 - column 5 index2Are you trying this?
SELECT UI.INDEX_NAME, ui.owner , UI.TABLE_NAME , ui.index_type, parameters, listagg(column_name,',') within GROUP ( ORDER BY column_position) column_name FROM all_INDEXES UI JOIN all_IND_COLUMNS UIC ON ( UIC.INDEX_NAME = UI.INDEX_NAME and uic.index_owner = ui.owner) WHERE SUBSTR(ui.index_name,1,3) NOT IN ('PK_', 'UQ_','DR$') AND ui.index_name NOT LIKE 'SYS_C00%' AND ui.index_name NOT LIKE 'SYS_IOT_TOP_%' GROUP BY UI.INDEX_NAME, ui.owner , UI.TABLE_NAME , ui.index_type, parameters ORDER BY UI.INDEX_NAME;
-
am getting error error when am with funcation wm_concat.
Hi all
am getting error error when am with funcation wm_concat.
Thanks to all in advanceSQL> DECLARE 2 ex VARCHAR2(200); 3 BEGIN 4 SELECT wm_concat(ename) INTO EX FROM EMP WHERE deptno=30; 5 DBMS_OUTPUT.PUT_LINE(EX); 6 END; 7 8 . SQL> SQL> / DECLARE * ERROR at line 1: ORA-06550: line 4, column 10: PL/SQL: ORA-00904: "WM_CONCAT": invalid identifier ORA-06550: line 4, column 3: PL/SQL: SQL Statement ignored
Published by: Maldini on 9 January 2012 22:02Cool wrote:
HelloPlease check the version of database you are using.
wm_concat is available from 11 g Release 2.
Incorrect answer.
wm_concat is undocumented and should not be used.
Even Tom Kyte tell you... Re: SEPARATE does not not with wmsys.wm_concat
11 GR 2, there is a documented feature called LISTAGG...
http://docs.Oracle.com/CD/E11882_01/server.112/e26088/functions089.htm
-
WM_CONCAT() not available
Hello
I tried the below in Oracle 10 g XE.
In fact, my requirement is, I have a table named "table1" that has a column ID.
The values are:
I need the result form:1 2 3 4
I tried the query below:1,2,3,4
Two permits ORA-00904.select wm_concat(ID) from table1 select listagg(ID,',') from table1
Please help me to achieve this goal.
Thank youTry this-
SELECT rtrim(xmlagg(xmlelement(e,column_name,',').extract('//text()')),',') aa from TABLE_NAME;
-
Hello
I am using Oracle 11g, and I have a question about the following.
I have a table with the following data
Value of category name
AA 01 012
AA 02 63-123
BB 01 012
BB 02 63-114
03 55 BB
CC 01 088
DD 01 088
DD 02 63-145
03 65 DD
I need to extract the data in the following format
Name 01 02 03
AA 012 63-123
BB 012 55 63 - 114
CC 088
DD 088 65 63 - 145
How should I do for this?
I tried to use the wm_concat function, then using substr to extract each item, but the wm_concat function will extract some lines in the sequence (01,02,03) and other lines of the sequence (01,03,02). What can I do?
Thank you.SQL> -- generating sample data SQL> with t as ( 2 select 'AA' name, '01' category, '012' value from dual union 3 select 'AA', '02', '63-123' from dual union 4 select 'BB', '01', '012' from dual union 5 select 'BB', '02', '63-114' from dual union 6 select 'BB', '03', '55' from dual union 7 select 'CC', '01', '088' from dual union 8 select 'DD', '01', '088' from dual union 9 select 'DD', '02', '63-145' from dual union 10 select 'DD', '03', '65' from dual 11 ) 12 -- 13 -- actual query: 14 -- 15 select name 16 , max(decode(category, '01', value)) "01" 17 , max(decode(category, '02', value)) "02" 18 , max(decode(category, '03', value)) "03" 19 from t 20 group by name 21 order by name; NA 01 02 03 -- ------ ------ ------ AA 012 63-123 BB 012 63-114 55 CC 088 DD 088 63-145 65
-
Hello
Is it possible to put the values in the WM_CONCAT function:
Statement:
wm_concat (rental_next_date) rental_date,
Output:
25-FEB-11,25-OCT-12,25-APR-12,25-DEC-11,25-APR-11
The above dates is controllable by Crescent?
Thank yousliderrules wrote:
Thank you all for your comments. The listagg has no effect on the order of dates.That's because you ordered solely on the id. If you want to order on the dates, you will have to ask him.
-
Hi all
I need a suggestion that one we should use wm_concat or listagg.
My db is 11g Standard Edition.
Please Guide!Yes, that's wht which suggest to my blog...
Alexander gelin
http://nimishgarg.blogspot.com -
Question about the correct use of the WM_CONCAT
Hello
I am trying to accomplish the following:
from this
and ends on thisENAME ---------- ADAMS ALLEN BLAKE ...
Basically, alphabetically sort the characters within each name. I have an intermediate step that seems promisingOLD_NAME NEW_NAME ---------- -------- ADAMS AADMS ALLEN AELLN BLAKE ABEKL ...
Yields aboveselect e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos from emp e, (select rownum pos from emp) iter where iter.pos <= length(e.ename) order by e.ename, substr(e.ename, iter.pos, 1);
the characters are in the right sequence, I thought that all I had to do was to use WM_CONCAT (and replace the comma it inserts with an empty string) and I would like to make. I thought it would do: (replacement of commas left out for clarity)OLDNAME NEWCHARPOS ---------- -------------------- ADAMS A ADAMS A ADAMS D ADAMS M ADAMS S ALLEN A ALLEN E ALLEN L ALLEN L ALLEN N BLAKE A BLAKE B BLAKE E BLAKE K BLAKE L ...
but the sequence of the newcharpos is messed up in the process and, rather than the expected result, I get this:select oldname, wm_concat(newcharpos) newname from ( select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos from emp e, (select rownum pos from emp) iter where iter.pos <= length(e.ename) order by e.ename, substr(e.ename, iter.pos, 1) ) group by oldname;
My question is, how to structure the last query so that the order of character as calculated in the inner query stays?OLDNAME NEWNAME ---------- -------------------- ADAMS A,S,M,D,A ALLEN A,N,L,L,E BLAKE A,L,K,E,B ...
Thank you for your help,
John.Or
SQL> select oldname, wm_concat(newcharpos) keep (dense_rank last order by null) newname from ( select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos from emp e, (select rownum pos from emp) iter where iter.pos <= length(e.ename) order by e.ename, substr(e.ename, iter.pos, 1) ) group by oldname / OLDNAME NEWNAME ---------- ------------------------------ ADAMS A,A,D,M,S ALLEN A,E,L,L,N BLAKE A,B,E,K,L CLARK A,C,K,L,R FORD D,F,O,R JAMES A,E,J,M,S JONES E,J,N,O,S KING G,I,K,N MARTIN A,I,M,N,R,T MILLER E,I,L,L,M,R SCOTT C,O,S,T,T SMITH H,I,M,S,T TURNER E,N,R,R,T,U WARD A,D,R,W 14 rows selected.
Or (11 GR 2)
SQL> select ename oldname, column_value newname from emp, xmltable(('string-join(for $i in (' || rtrim(regexp_replace(ename, '(.)', '"\1",'),',') || ') order by $i return $i, "")')) / OLDNAME NEWNAME ---------- ------------------------------ SMITH HIMST ALLEN AELLN WARD ADRW JONES EJNOS MARTIN AIMNRT BLAKE ABEKL CLARK ACKLR SCOTT COSTT KING GIKN TURNER ENRRTU ADAMS AADMS JAMES AEJMS FORD DFOR MILLER EILLMR 14 rows selected.
-
Chr (10) and WM_CONCAT in a statement?
Hello
Got a query
The results are:SELECT wm_concat(col1) "TEST" FROM TAB T WHERE t.NAME=vName
TEST
T1, t2, t3...
What I want is
T1,
T2,
T3,
.
.
.
How can I get it? I tried with Chr (10), but she just added a space after the «,»Do not forget WM_CONCAT in the undocumented. In any case:
SQL> select wm_concat(chr(13) || chr(10) || ename) from emp; WM_CONCAT(CHR(13)||CHR(10)||ENAME) -------------------------------------------------------------- SMITH, ALLEN, WARD, JONES, MARTIN, BLAKE, CLARK, SCOTT, KING, TURNER, WM_CONCAT(CHR(13)||CHR(10)||ENAME) -------------------------------------------------------------- ADAMS, JAMES, FORD, MILLER SQL>
SY.
-
When ran the following query, I got the enames unordered result. Does anyone know how to get the wm_concat to the order\sort column? I use oracle v10. Any thoughts are appreciated. Thank you.
Select distinct deptno, wm_concat (ename) over (partition by deptno arrested by deptno) as enames
WCP
Ename, deptno group
order by deptno
output current:
The target output:DEPTNO ENAMES 10 MILLER,CLARK,KING 20 SCOTT,JONES,FORD,ADAMS,SMITH 30 MARTIN,JAMES,WARD,ALLEN,TURNER,BLAKE
WanwanDEPTNO ENAMES 10 CLARK,KING,MILLER 20 ADAMS,FORD,JONES,SCOTT,SMITH 30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
wm_concat is undocumented. so please do not use it. You can use the following query. It also solves your problem order.
select deptno, ltrim(sys_connect_by_path(ename,','),',') from (select deptno, ename, row_number() over(partition by deptno order by ename) rno from emp) where connect_by_isleaf = 1 connect by deptno = prior deptno and rno = prior rno+1 start with rno = 1
-
Dear friends.
I face this error
ORA-06502: PL/SQL numeric or value error: character string buffer too small.
ORA-06512: at the ' WMSYS '.»» WM_CONCAT_IMPL ".
I keep files on my table and I want to display records in separate by commas.
output 101,101,102,103 there are a thousand documents in the column.
but when I used above function to concatenate its gave me error.
Please help me or give me another Solution on it how do I record with comma.output 101,101,102,103 there are a thousand documents in the column.
See this example:
SQL> select deptno, rtrim (xmlagg (xmlforest (empno || ',' e)).extract ('//text()').getclobval (), ',') empnos from emp group by deptno / DEPTNO EMPNOS ---------- ---------------------------------------- 10 7782,7839,7934 20 7369,7902,7876,7788,7566 30 7499,7698,7654,7844,7900,7521 3 rows selected.
-
Small question:
What version of sql is running forms 12 c?
Long version:
We have a form application of 11g (with database 11g of forms)
We want to test 12 c and 12 c database forms
We have set up a database of 12 c, but has a few problems compiling with WM_CONCAT. We solved easily to server-side rewrite the sentences of sql (using the LISTAGG) and leave it that way for future migration.
The problem: Forms 11g does not support the LISTAGG (like many other sql and pl 'new' functions). No problem, we can wait until this date future migration, but... Made to support 12 c listagg function?
Thank you.
Listagg was introduced in the 11g database. As analytc as it did not fit 11g. I didn't try it in 12 c, but if the .dll Version numbers are trustworthy the plsql.dll is always Version 11 to 12 forms, so I think that it still does not. In any case, I wouldn't mind a lot and use a view of your statement containing listagg.
See you soon
-
Need to extract query text in each row tags
I need to display a list of tags used in particular the text for each line. After sample data can give clear you the idea.
DB version:
========
Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production
Sample data:
==========
WITH txt_data AS)
SELECT the 1 id, txt "your price #toy_name # is #price_amt #.» FROM DUAL
UNION ALL
SELECT id 2, "it's product tag #pdt_tag #." It is a client #clt_tag tag # and finally this notice tag #adv_tag #. ' txt FROM DUAL
UNION ALL
SELECT 3 id, "Hi Mr. #clt_name #." txt FROM DUAL
)
SELECT * FROM txt_data;
Power required:
============
ID TAGS 1 #toy_name #, #price_amt #. 2 #pdt_tag #, #clt_tag #, #adv_tag #. 3 #clt_name #. To implement this I used the technique of factoring of the recursive subquery for a static data (row). Seen the query below.
WITH tag_list (ip_str, case, tag) as)
SELECT ' this is product #pdt_tag tag #. It is a client #clt_tag tag # and finally this notice tag #adv_tag #. ' AS ip_str, 0 accident AS, null AS tag FROM DUAL
UNION ALL
SELECT ip_str, here + 1, REGEXP_SUBSTR (ip_str, ' (#. *?)) (#)', 1, case + 1) OF tag_list WHERE REGEXP_SUBSTR (ip_str, ' (#. *?)) (#)', 1, case + 1) IS NOT NULL
), SELECT WMSYS. WM_CONCAT (tag) OF tag_list WHERE case > 0;
But when I use this technique for the data in the table, it gives me the error. Given below.
WITH txt_data AS)
SELECT the 1 id, txt "your price #toy_name # is #price_amt #.» FROM DUAL
UNION ALL
SELECT id 2, "it's product tag #pdt_tag #." It is a client #clt_tag tag # and finally this notice tag #adv_tag #. ' txt FROM DUAL
UNION ALL
SELECT 3 id, "Hi Mr. #clt_name #." txt FROM DUAL
)
SELECT t.id,
(WITH tag_list (ip_str, case, tag) as ())
SELECT t.TXT AS ip_str, 0 accident AS, null AS tag FROM DUAL
UNION ALL
SELECT ip_str, here + 1, REGEXP_SUBSTR (ip_str, ' (#. *?)) (#)', 1, case + 1) OF tag_list WHERE REGEXP_SUBSTR (ip_str, ' (#. *?)) (#)', 1, case + 1) IS NOT NULL
), SELECT WMSYS. WM_CONCAT (tag) OF tag_list WHERE case > 0) as tags
OF txt_data t.
ORA-00904: "T". "" TXT ": invalid identifier
00904, 00000 - '% s: invalid identifier '.
* Cause:
* Action:
Error on line: column 50: 17
Issues related to the:
----------------
1. help reach my goal (with your own logic, whatever my technique)
2. What is the problem with my technique above? Cannot use us WITH the clause in the selection list?
Thanks in advance
Personally I would rewrite the expression of regexp as ' #[^ #] * #'
In addition, we can get rid of the place where the main expression
with tag_list (ip_str, case, tag) as)
SELECT TXT AS ip_str, 1 match AS
REGEXP_SUBSTR(txt, '#[^#]*#', 1, 1) AS tag
of txt_data
UNION ALL
SELECT ip_str, here + 1
, REGEXP_SUBSTR (ip_str, ' #[^ #] * #', 1, case + 1)
OF tag_list
WHERE REGEXP_SUBSTR(ip_str, '#[^#]*#', 1, occurrence + 1) IS NOT NULL
)
SELECT
ip_str
, listagg (tag, ',') within the Group (by instance) s
OF tag_list
Ip_str group
Finally, you can save a regexp_substr
with tag_list (ip_str, case, tag) as)
SELECT TXT AS ip_str, 1 match AS
REGEXP_SUBSTR(txt, '#[^#]*#', 1, 1) AS tag
of txt_data
UNION ALL
SELECT ip_str, here + 1
, REGEXP_SUBSTR (ip_str, ' #[^ #] * #', 1, case + 1)
OF tag_list
)
cycle tag cyl set default 1 0
SELECT
ip_str
, listagg (tag, ',') within the Group (by instance) s
OF tag_list
Ip_str group
Maybe you are looking for
-
Satellite L670 loses internet connection
Hello, since a few days my laptop loses its internet connection when I move a few meters or put me behind a window. In this case, I am sitting the router to 2 meters maximum. The power of wireless transmission is very good according to the screen, bu
-
Satellite L775-130 - how to remove the BIOS password
Hi, I have a L775-130 satellite whereby you have the bios password and no way to remove, all solutions? Thank you all...
-
I bought a laptop HP pavilion 15-p203tx about 6 months ago. It came with windows pre-installed 8.1 64-bit. It is workng everything fine and smooth. Just a little while back, I received my upgrade reserved windows 10. I upgraded my laptop with the sam
-
Can't boot from USB Flash Drive on Yoga 13
I had a USB bootable with linux on it live and I tested it it works on another computer but I can't get my Yoga to boot from it. I wet to settings-> General-> advanced startup and then I clicked on the option USB but the computer is restarted, he sai
-
I used Readyboost for quite a while with a stick of scandisk. All of a sudden it would not work. Now I can not find Readyboost anywhere on my computer and I used to see it on my list of programs, I'm not having any other problems with the computer I