Comma Separated Values
HelloWe stock values separated by commas into a table.
IIL_CUSTOMER_TICKETS_TYPE_IDS
-------------------------------------------------------
1,2,3,4,5,6
5,7,10,56,48
12,45,56,
I want to query this table through values separated by commas...
Query as this select * from t1 where IIL_CUSTOMER_TICKETS_TYPE_IDS in (1,2,3)
Help, please...
Try this
with mytable as
(
Select 'a' pass, ' 1,2,3,4,5,6"txt of all double union
Select 'b', '5,7,10,56,48' of any double union
Select 'c', "12,45,56" of the double
)
Select
MyTable.col,
txt
Of
MyTable,
(
Select
level n
Of
(
Select
Max (length (txt) - length (replace (txt, ','))) as max_commas
Of
MyTable
)
connect by level<= 1="" +="">=>
) ctr
where
CTR.n<= 1="" +="" length="" (txt)="" -="" length="" (replace="" (txt,="">=>
and regexp_substr (mytable.txt, "[^,] +', 1, n") in (1,5,7)
order by
MyTable.col,
CTR.n
http://nimishgarg.blogspot.com/2010/06/Oracle-comma-seprated-string-to-rows_16.html
Alexander gelin
http://nimishgarg.blogspot.com
Tags: Database
Similar Questions
-
The research of a column with comma separated values with ora-text
I use the Oracle 11 g 2 XE and Oracle Text to a web search engine.
I've now created and text indexed a CLOB keywords column that contains words separated by spaces. This allowed me to expand the search, as Oracle Text returns the rows that have one or more keywords that are stored in this column. The contents of the column are visible to the user and serves to 'expand' the search. This does not work as expected.
But now I need support several words or even sentences. With the current configuration, Oracle Text will only search for each keyword. How should I store the phrases and configure Oracle text so that it will search entire sentences (exact match is better, but the partial match is fine too)?
Example of content column of two lines (values separated semicolon):
"Hello, Hello; y at - it anyone out there? Nope; »
"the just; basic facts; »
I found a similar question: looking for a column with values separated by commas, except that I need a solution for Oracle 11 g with it's freetext search.
Possible solutions:
1st solution: I thought to redraw the DB as follows. I would like to make a new array of keywords (pkID NUMBER, nonUniqueID NUMBER, singlePhrase VARCHAR2 (100 BYTE)). And I want to change the column previous keyword to KeywordNonUniqueID, holding the ID (instead of a list of values). At the time of the research I had INNER JOIN with the new keyword table. The problem with this solution is that I will get several lines containing the same data except for the sentence. I guess this will destroy the ranking?
2nd solution: is it possible to store sentences as an XML in the column key of origin and somehow say Oracle text to search for in the XML?
3rd solution: separate individual phrases with spaces, but replace the spaces in sentences with the underscore or something (making a single word). If a phrase "why Hello there, Johnny!" is saved as "Why_hello_there, _Johnny!
4th solution?:
Note that, generally, there is a lot of sentences (less than 100), nor that they will be long (one sentence will be up to 5 words).
Also note that I am currently using CONTAINS, and needs some of its operators, to my full-text searches.When you talk about "phrase", do you mean "a list of words separated by a comma other sentences?
Isn't that the definition of "sentence" used by Oracle Text, where it simply means "a list of words in the order defined."
If I understand your requirement, you want to have data such as:
"aa bb cc dd".
"aa ee dd ff.and give priority to the first on the second if someone looking for "dd".
First, to conduct research in the comma separated list, you should look for in a section. You can either explicitly define sections of field such as
AA bb cc dd
Or you can use the PHRASE special section and set the sentence delimiters correctly. This is done with the attribute BASIC_LEXER punctuationThen you have the number you want to find only words where they are the only words in the section. That's the same problem, I address in the last post of this forum entry:
Contains: match exactlyOur solution will be substantially the same, some surrounding text with special markers, and then prioritize a phrase search with these special markers each side of the word.
We need to do a treatment some additional, although, as we need to surround each "sentence" (in your terminology) with special markers. I did it by surrounding the text with "XX1"... Condition2"then by replacing every comma with"Condition2, XX1"as part of a MULTI_COLUMN_DATASTORE:drop table names; create table names (id number primary key, text varchar2(50)); insert into names values( 1, 'just and kind, kind and loving' ); insert into names values( 2, 'just, kind' ); exec ctx_ddl.drop_preference ( 'mylex' ) exec ctx_ddl.create_preference( 'mylex', 'BASIC_LEXER' ) exec ctx_ddl.set_attribute ( 'mylex', 'PUNCTUATIONS', ',' ) exec ctx_ddl.drop_preference ( 'mcds' ) exec ctx_ddl.create_preference( 'mcds', 'MULTI_COLUMN_DATASTORE' ) exec ctx_ddl.set_attribute ( 'mcds', 'COLUMNS', '''XX1 ''||replace(text, '','',''XX2, XX1'')||'' XX2''' ) exec ctx_ddl.drop_preference ( 'mywl' ) exec ctx_ddl.create_preference( 'mywl', 'BASIC_WORDLIST' ) exec ctx_ddl.set_attribute ( 'mywl', 'SUBSTRING_INDEX', 'YES' ) create index namesindex on names(text) indextype is ctxsys.context parameters( 'datastore mcds wordlist mywl' ) / select score(1),id,text from names where contains( text, '
XX1 kind XX2 kind Output of this is:
SCORE(1) ID TEXT ---------- ---------- -------------------------------------------------- 52 2 just, kind 2 1 just and kind, kind and loving
-
creation of selection using comma-separated values list
Hi all
I have the column in the database containing values separated by commas
for ex: Pune, Mumbai, Bangalore...
I want to create the selection list using higher values.
for ex: Pune
Mumbai
Bangalore
Please help me on this issue.
Thanks in advance,
JitendraHello
Try the following
select regexp_substr(YOUR_FIELD_NAME,'[^,]+', 1, level) display_value, regexp_substr(YOUR_FIELD_NAME,'[^,]+', 1, level) return_value from YOUR_TABLE connect by regexp_substr(YOUR_FIELD_NAME, '[^,]+', 1, level) is not null
Concerning
Graham
Published by: gpc on February 1, 2012 11:27
-
Using 'text field contains comma-separated values' on a parameter of %
Hello
I use a parameter that has more than one value to be entered, separated by commas. I checked the box 'text field contains values separated by commas' for the parameter and set the sql code by using the operator 'in' so that the column will look in the multiple input values (e.g. family name in (: surname_par)). However, as passing multiple values parameter must also be able to manage %'s. As the sql uses the 'in' operator, BI Publisher brings back an error because % is supposed to bring all family names and not people with a last name of %. Is there a way to get around this?
Thank youIf you try to pass multiple values separated by commas and in addition also takes the query to return the data when the user types just in '%', then you could write something like this in your query:
Select * from table_name
where ((1 = DECODE (: surname_par, '%', 1, 0)) OR family name in (: surname_par))I hope this helps. Please award points if helpful/correct.
-
Comma Separated Values in Bind Variable
Hello
I'm on Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production.I use in query
It gives me two rows as it should. Now, I want to pass these values as a bind variable.select * from employees where first_name in ('Ajay','Ajay5')
Now when I run the query and make its contribution as a ('Ajay', 'Ajay5'). It gives me no line.select * from employees where first_name in :1
Is their any way to do this. Let me know if you have any questions
Thank you
AJCheck out this link: the Blog of Tom Kyte: varying in lists...
-
Order with comma separated values?
I have the following table
create table ord as
(select col1 '4,7,10'
Union
"4,7,8'."
Union
'5,6,11'
Union
'4,7,10'
Union
'4,7,6'
Union
'4,7,7'
the double)
I mean select * from DSB order by col1 and the by should look at every number in the column ordering him to string vs...
Currently 4,7,10 comes first (as it is a string comparison), but I want to come 4,7,6 first.It could by urgent for you, but it is not, we have our own work to do.
In any case...
It will focus on any number of numbers in the list up to 10 digits long each...
SQL> ed Wrote file afiedt.buf 1 with ord as 2 (select '4,7,10' col1 from dual union 3 select '4,7,8' from dual union 4 select '5,6,11' from dual union 5 select '4,7,10' from dual union 6 select '4,7,99,4' from dual union 7 select '4,7,6' from dual union 8 select '4,7,7' from dual) 9 -- End of test data 10 select col1 11 from ord 12* order by regexp_replace(regexp_replace(col1,'(^|,)([^,]+)','\1000000000\2'),'(^|,)[^,]*([0-9]{10})(,|$)','\1\2\3') SQL> / COL1 -------- 4,7,6 4,7,7 4,7,8 4,7,10 4,7,99,4 5,6,11 6 rows selected. SQL>
If you need to more digits cos you're numbers are bigger, so you need to change the regular expression to pad with more than 0 (inbetween the \2 \1) and cut to the required length or replace the {noformat} {10} {noformat} with the number of digits required.
-
SQL - Multiple Fetch in a single column with a comma separator
Hello Experts,
Good day to all...
I need your help on the following scenarios. The following query returns all channels titleID. Rather than print them one under the other as a result of the query, I want the output to be in the batch of 25 values.i.e than each line must have 25 values separated by commas. IE if there are 100 titles satisfying the output, then there should be only four lines with and each line with 25 titles in comma separated way.
I tried with the PL/SQL block; Whereas it is printing all the values permanently :(SELECT DISTINCT title_id FROM pack_relation WHERE package_id IN ( SELECT DISTINCT fa.package_id FROM annotation fa GROUP BY fa.package_id HAVING COUNT (fa.package_id) <100);
I have to stop with 25 values and display.
If its possible with SQL block alone. then it would be a great help
Thank you...DECLARE v_str VARCHAR2 (32767) := NULL; CURSOR c1 IS SELECT DISTINCT title_id FROM pack_relation WHERE package_id IN ( SELECT DISTINCT fa.package_id FROM annotation fa GROUP BY fa.package_id HAVING COUNT (fa.package_id) <100); BEGIN FOR i IN c1 LOOP v_str := v_str || ',' || i.title_id; END LOOP; v_str := SUBSTR (v_str, 2); DBMS_OUTPUT.put_line (v_str); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line ('Error-->' || SQLERRM); END;
You can use CEIL
Code example
SELECT nt, LTRIM(MAX(SYS_CONNECT_BY_PATH(val,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val FROM ( SELECT val, nt, ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val) AS curr, ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val) -1 AS prev FROM ( SELECT level AS val, ceil(rownum/3) as nt /* Grouped in batches of 3 */ FROM dual CONNECT BY level <= 10 ) ) GROUP BY nt CONNECT BY prev = PRIOR curr AND nt = PRIOR nt START WITH curr = 1; NT CONCAT_VAL ---------- -------------------------------------------------------------------------------- 1 1,2,3 2 4,5,6 3 7,8,9 4 10
Your code
SELECT nt, LTRIM(MAX(SYS_CONNECT_BY_PATH(title_id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val FROM ( SELECT title_id, nt, ROW_NUMBER () OVER (PARTITion BY nt ORDER BY title_id) AS curr, ROW_NUMBER() OVER (PARTITION BY nt ORDER BY title_id) -1 AS prev FROM ( SELECT title_id, ceil(rownum/25) AS nt /* Grouped in batches of 25 */ FROM pack_relation tdpr JOIN annotation fa ON tdpr.package_id = fa.package_id GROUP BY title_id, fa.package_id HAVING COUNT (fa.package_id) < 500 ) ) GROUP BY nt CONNECT BY prev = PRIOR curr AND nt = PRIOR nt START WITH curr = 1;
-
I have a string that comes an external instrument. When it is read, he appears in a format like this:
"10,55.
11.25
13.43
15.68 "
The number of entries varies. I need to get this string in a comma-separated string that is later concatenated with another string and written to a csv file.
So how do the entry above into this: ' 10,55, 11.25, 13.43 15.68?
Thank you
There are a lot of ways. I use find and replace. See attachemt for an example.
-
Adding zero in comma separated string
Hi all
Currently I am working on Oracle 11 g
I have the string as 1,12,123,1234 and my requirement is to fill the zero on every comma separated string
My output result should be like this 0001,0012,0123,1234, what exactly does lpad('12',4,'0').
Kindly help a query above.
A simple trick I learned for a long time back here
SQL> with t 2 as 3 ( 4 select '1,12,123,1234' str from dual 5 ) 6 select regexp_replace(regexp_replace(str, '([[:digit:]]+)', '0000\1'), '0+([[:digit:]]{4})', '\1') str 7 from t; STR ------------------- 0001,0012,0123,1234 SQL>
-
Hello
In Oracle 10 g, I need to split comma separation like that.
data:
'1,3,2,3,4,6'
to divide like this
Col1 col2
1 3
2 3
4 6
Thanks in advance
Hello 00125
This might be a solution:
WITH TMP_TAB
AS (SELECT '1,3,2,3,4,6' AS DOUBLE TXT)
SELECT REGEXP_SUBSTR (txt, ' [^,] +', 1, 2 + 1 *(level-1)) AS Col1
REGEXP_SUBSTR(txt, '[^,]+', 1, 2*level) AS Col2
OF TMP_TAB
CONNECTION OF level <= round((length(txt)="" -="" length(replace(txt,="" ',')))="" 2) ="" --="">10g characteristic
;
Less than 11g, you can write it's simpler:
CONNECTION OF <= regexp_count(txt="" ||="" ',',="" ',')="" 2 ="" --="">11g characteristic level
=>=>
I hope it helps.
Best regards, David
-
I can't get my calculations right away, even after the selection "commit selected value immediately" on my drop-down menus. Any ideas?
The field calculation order is probably not set correctly. The specific configuration procedure it depends on which version of Acrobat you are using. Acrobat 11, you would go first in forms editing mode (Tools > forms > change), and then select:
Tasks > other tasks > set field calculation order
-
Nice day
I created the report and the displayed value not have commas in values such as "3,20,000", my values are displayed as '320000.
How to add commas in the apex.
Kind regards
OMZHello
Version of the apex?
Classic report / IR?Try to set the attributes of report > Edit Column > column attributes > number / Date Format
See you soon,.
-
Need to convert coma separated values
Need to convert coma separated values
I have a string value that stores the data as "NYK, IND, GSP, GER.
FOR EXAMPLE
V_CITY_CODE = 'NYK, IND, GSP, GER'
When I query
I get no line, it's because V_CITY_CODE has all the code of city as unique code.select * from city where city_code = V_CITY_CODE;
I need a function to search and replace by ",".
I tried to use instr and replace but was unable to convert.
could someone help me pls.
Thanks in advance
SAZThe research of this?
SQL> select * from emp 2 / EMPNO DEPTNO ENAME SAL DOJ JOB ---------- ---------- ------------------------------ ---------- --------- -------------------- 1 1 Karthick 80 03-DEC-11 2 1 Karthick_1 90 23-NOV-11 3 2 Ram 80 03-DEC-11 4 2 Ram_1 90 23-NOV-11 SQL> var v_ename varchar2(1000) SQL> exec :v_ename := 'Karthick,Karthick_1' PL/SQL procedure successfully completed. SQL> select * 2 from emp 3 where ename in ( 4 select regexp_substr(val, '[^,]+', 1, level) 5 from (select :v_ename val from dual) 6 connect by level <= length(val) - length(replace(val, ','))+1 7 ) 8 / EMPNO DEPTNO ENAME SAL DOJ JOB ---------- ---------- ------------------------------ ---------- --------- -------------------- 1 1 Karthick 80 03-DEC-11 2 1 Karthick_1 90 23-NOV-11
-
Count the values in a comma separated string
Hi, I have the following requirement.
The entry is as below:
And production is expected to be of the island belowwith test as (select 'ABC,DEF,GHI,JKL,MNO' mystring from dual union all select 'ABC,DEF' from dual union all select 'JKL,MNO' from dual ) select * from test
I tried this query to get, as above, but the wrong exitstr cnt 'ABC' 2 'DEF' 2 'GHI' 1 'JKL' 2 'MNO' 2
Please help me to get the output as requiredwith test as (select 'ABC,DEF,GHI,JKL,MNO' mystring from dual union all select 'ABC,DEF' from dual union all select 'JKL,MNO' from dual ) select str,count(*) from ( select regexp_substr(mystring,'[^,]+',1,level) str from test connect by level <= length(regexp_replace(mystring,'[^,]+')) + 1 ) group by str
Thank youSQL> with test 2 as 3 ( 4 select 'ABC,DEF,GHI,JKL,MNO' mystring from dual union all 5 select 'ABC,DEF' from dual union all 6 select 'JKL,MNO' from dual 7 ) 8 select str, count(*) 9 from ( 10 select regexp_substr(mystring, '[^,]+', 1, level) str 11 from test 12 connect by level <= length(mystring) - length(replace(mystring, ',')) + 1 13 and mystring = prior mystring 14 and prior sys_guid() is not null 15 ) 16 group 17 by str 18 order 19 by str 20 / STR COUNT(*) ------------------- ---------- ABC 2 DEF 2 GHI 1 JKL 2 MNO 2
-
to display several values in the column as a simple comma separated
Hello..
My the source table structure is as
test_123
person_id varchar2,
phone_no varchar2
A unique person_id can have several phone_nos
as
person_id phone_no
123 1245
123 1246
123 1247
12460 124
124 12461
Now I want the output voltage
person_id phone_no
123 1245,1246,1247
124 12460,12461
How d she?
I want it in a single query?Many many many examples here.
http://www.Oracle-base.com/articles/Misc/StringAggregationTechniques.php
Maybe you are looking for
-
Shortcuts to other programs only open in Word 2007 after upgrading to Firefox 17
I already have shortcuts to Volgistics and Facebook on my desktop when I've recently updated to Firefox 17. Since the update, these shortcuts directly from these programs to Word 2007, which opens the program read-only in Word 2007. I can, however, c
-
Satellite c855 - VGA port suddenly does not work
Hi people I have the toshiba satellite-c855 - 17 c. Windows 7.Usually, I work on my laptop and monitor, which I use by plugging the vga cable. I use this set to the top for more than a year and never had any problems. Now, nothing happens when I plug
-
How to remove the user password in the Vista operating system
HelloMy son has a Toshiba laptop that he changed the password of today.Unfortunately, even if he had to type it in twice, he managed to kick it wrongly.So he now can't get into his laptop at all. Is there a way around to type the password?It has Wind
-
I got a new 802.11ac 3 TB time capsule and I would use my Airport Extreme 802.11n as an Extender but I fear that 802.11n is too old technology.
-
My recovery disk is full (905Mb left free) can someone tell me how to free up more space than the failure of the backup sytem now, I tried to delete the file, but it make no difference to the total space used. Thank you very much