Counting the values in comma separated string
Hi I've the following requirement .
The input is like below:
with 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 testAnd the output should be lile below
str cnt
'ABC' 2
'DEF' 2
'GHI' 1
'JKL' 2
'MNO' 2I tried the following query to get like above but getting the wrong output
with 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 strPlease help me to get the ouput as required
Thanks
You are almost close:
WITH 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 (SELECT ROWNUM r, test.* FROM test) test
CONNECT BY LEVEL <= REGEXP_COUNT (mystring, ',') + 1
AND PRIOR SYS_GUID () IS NOT NULL
AND r = PRIOR r)
GROUP BY str
ORDER BY 1Output:
STR COUNT(*)
ABC 2
DEF 2
GHI 1
JKL 2
MNO 2Cheers,
Manik.
Similar Messages
-
Read/Insert values from comma separated string
I need Stored procedure to insert values in table using comma separated values from string based on algorithm as below.
There are two table Mtable(Parent table), Ctable(Child table).
Value passed from String can be like_
1,A001,R1,C1,R2,C2,R3,C3
2,A002,X1,Y1,X2,Y2
3,A003,A1,B1,A2,B2,A3,B3
1)For line1 I need to insert in Mtable values(1,A001)
And in ctable I need to insert 3 rows with values
ROW1 (1,R1,C1)
ROW2 (1,R2,C2)
ROW3 (1,R3,C3)
2)For line2 I need to insert in Mtable values(2,A002)
And in ctable I need to insert 2 rows with values
ROW1 (2,X1,Y1)
ROW2 (2,X2,Y2)
Please help me to overcome this.
Thankscreate table t as
select '1,A001,R1,C1,R2,C2,R3,C3' s from dual union
select '2,A002,X1,Y1,X2,Y2' from dual union
select '3,A003,A1,B1,A2,B2,A3,B3' from dual
Table created
select substr(s,1,instr(s,',')-1),
substr(s,instr(s,',',1,2*i)+1,instr(s||',',',',1,2*i+1)-instr(s,',',1,2*i)-1),
substr(s,instr(s,',',1,2*i+1)+1,instr(s||',',',',1,2*i+2)-instr(s,',',1,2*i+1)-1
from t, (select 1 i from dual union select 2 from dual union select 3 from dual)
where instr(s,',',1,2*i+1)>0
order by 1,i
SUBSTR(S,1,INSTR(S,',')-1) SUBSTR(S,INSTR(S,',',1,2*I)+1, SUBSTR(S,INSTR(S,',',1
1 R1 C1
1 R2 C2
1 R3 C3
2 X1 Y1
2 X2 Y2
3 A1 B1
3 A2 B2
3 A3 B3
8 rows selected -
Revision: 15983
Revision: 15983
Author: [email protected]
Date: 2010-05-10 04:47:46 -0700 (Mon, 10 May 2010)
Log Message:
Updating VideoQoSPluginMetadataSynthesizer to create comma separated string values for all of the available keys.
Modified Paths:
osmf/trunk/apps/samples/plugins/VideoQoSPlugin/src/org/osmf/qos/VideoQoSPluginMetadataSyn thesizer.asRob:
"but the sad thing is, that managers will most likely respond with a "This used to be fast in MSSQL, but now it isn't any more in Oracle. Oracle is so slow ...""
On the bright side, it sounds like most of the database calls are implemented as stored procedures, so there is an opportunity to do it right (in Oracle terms) in the stored procedures.
I did a similar conversion a while back, converting bad SQLServer procedures to good Oracle procedures. Everyone said "Oracle is much faster that SQLServer"
John -
MODEL clause to process a comma separated string
Hi,
I'm trying to parse a comma separated string using SQL so that it will return the parsed values as rows;
eg. 'ABC,DEF GHI,JKL' would return 3 rows;
'ABC'
'DEF GHI'
'JKL'
I'm thinking that I could possibily use the MODEL clause combined with REGULAR expressions to solve this as I've already got a bit of SQL which does the opposite ie. turning the rows into 1 comma separated string;
select id, substr( concat_string, 2 ) as string
from (select 1 id, 'ABC' string from dual union all select 1, 'DEF GHI' from dual union all select 1, 'JKL' from dual)
model
return updated rows
partition by ( id )
dimension by ( row_number() over (partition by id order by string) as position )
measures ( cast(string as varchar2(4000) ) as concat_string )
rules
upsert
iterate( 1000 )
until ( presentv(concat_string[iteration_number+2],1,0) = 0 )
( concat_string[0] = concat_string[0] || ',' || concat_string[iteration_number+1] )
order by id;
Can anyone give me some pointers how to parse the comma separated string using regexp and create as many rows as needed using the MODEL clause?Yes, you could do it without using ITERATE, but FOR ... INCREMENT is pretty much same loop. Couple of improvements:
a) there is no need for CHAINE measure
b) there is no need for CASE in RULES clause
c) NVL can be applies on measures level
with t as (select 1 id, 'ABC,DEF GHI,JKL,DEF GHI,JKL,DEF GHI,JKL,DEF,GHI,JKL' string from dual
union all
select 2,'MNO' string from dual
union all
select 3,null string from dual
SELECT id,
string
FROM T
MODEL
RETURN UPDATED ROWS
partition by (id)
DIMENSION BY (0 POSITION)
MEASURES(
string,
NVL(LENGTH(REGEXP_REPLACE(string,'[^,]+','')),0)+1 NB_MOT
RULES
string[FOR POSITION FROM 1 TO NB_MOT[0] INCREMENT 1] = REGEXP_SUBSTR(string[0],'[^,]+',1,CV(POSITION))
SQL> with t as (select 1 id, 'ABC,DEF GHI,JKL,DEF GHI,JKL,DEF GHI,JKL,DEF,GHI,JKL' string from dual
2 union all
3 select 2,'MNO' string from dual
4 union all
5 select 3,null string from dual
6 )
7 SELECT id,
8 string
9 FROM T
10 MODEL
11 RETURN UPDATED ROWS
12 partition by (id)
13 DIMENSION BY (0 POSITION)
14 MEASURES(
15 string,
16 NVL(LENGTH(REGEXP_REPLACE(string,'[^,]+','')),0)+1 NB_MOT
17 )
18 RULES
19 (
20 string[FOR POSITION FROM 1 TO NB_MOT[0] INCREMENT 1] = REGEXP_SUBSTR(string[0],'[^,]+',1,CV(POSITION))
21 )
22 /
ID STRING
1 ABC
1 DEF GHI
1 JKL
1 DEF GHI
1 JKL
1 DEF GHI
1 JKL
1 DEF
1 GHI
1 JKL
2 MNO
ID STRING
3
12 rows selected.
SQL> SY. -
Look Up For Comma Separated Strings
Hi,
How to look up for comma separated string from livecycle forms manager ??
Plz gimme an idea on this.
Raghava Kumar V.S.S.Hi
My point is that the more detailed you ask your question, the more likely you are to get an answer.
Those of us who monitor these newsgroups also appreciate you doing as much of your own research as possible, before asking us for help - we're more likely to spend our own (personal and valuable) time helping you, if we know that you've spent your own time doing research, and you've still not been able to solve the problem.
I look forward to your next question :-)
Howard -
Passing comma separated string to stored procedure
Hi,
There is thread with same query I created earlier and that was answered. That solution worked if I pass comma separated string containing IDs. But due to changes in the logic, I have to pass usernames instead of userIDs. I tried to modify the solution provided to use with this.
Following the link to previous post :
Re: Passing comma separated string to stored procedure
------Package-------
TYPE refcurQID IS REF CURSOR;
TYPE refcurPubs IS REF CURSOR;
procedure GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID
, TestPubs OUT Test.refcurPubs);
------Package-------
------Package Body-------
PROCEDURE GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID, TestPubs OUT Test.refcurPubs) as
BEGIN
Open TestQID for
select id from cfq where name in (p_user_name);
Open TestPubs for
SELECT qid FROM queues WHERE qid in(
select id from cfq where name in (p_user_name));
END GetAllPersonalQueue;
------Package Body-------
Thanks in advance
AdityaHi,
I modified the query as per the solution provided by isotope, after which the logic changed and I am passing username instead of userID in comma separated string.
Following is the changes SP, which does not throw any error, but no data is returned.
PROCEDURE GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID, TestPubs OUT Test.refcurPubs
) is
--local variable
strFilter varchar2(100);
BEGIN
Open TestQID for
select id, name from cfq where name in
select regexp_substr(p_user_name||',','[a-z]+[0-9]+',1,level)
from dual
connect by level <= (select max(length(p_user_name)-length(replace(p_user_name,',')))+1
from dual)
Open TestPubs for
SELECT qid FROM queues WHERE qid in(
select id from cfq where name in
select regexp_substr(p_user_name||',','[a-z]+[0-9]+',1,level)
from dual
connect by level <= (select max(length(p_user_name)-length(replace(p_user_name,',')))+1
from dual)
END GetAllPersonalQueue;
Edited by: adityapawar on Feb 27, 2009 8:38 AM -
One column having multiple values with comma separator.
Hey Guys,
In my db, one culmn having multiple values with comma separator. like column_name = 'value1,value2,value3'. Now I want to compare this column to another column and fetch in Cursor.
and each value having corresponding email_id, By fetching cursor, I need to populate email_ids.
Thanks in advance!!
-LakshmanPlease compare and fetch cursor and populate result with out extract data into temp table. Give me the query!You have not provided DDL for table so I don't know table or column name to write any SQL.
You have not provided DML for test data to run SQL against. -
Convert comma separated string in rows
Dear Gurus,
I want to convert comma separated string in rows so as to insert in collection.
e.g. string 1234,2323,23232,2343,34234
Above string should be converted in rows so as to insert in table or collection
Thanks in advance
SanjeevOr slight variation...
SQL> ed
Wrote file afiedt.buf
1 with t as (select '1234,2323,23232,2343,34234' as txt from dual)
2 --
3 select REGEXP_SUBSTR (txt, '[^,]+', 1, level)
4 from t
5* connect by REGEXP_SUBSTR (txt, '[^,]+', 1, level) is not null
6 /
REGEXP_SUBSTR(TXT,'[^,]+',
1234
2323
23232
2343
34234... so it doesn't have to work out how many levels it needs to do, it just keeps going until it get's a no-value (of course that assumes that there is always a value between each comma) -
How to find out the type of the value stored in a string variable?
Hi,
How do i find out the type of the value stored in a string variable?
for example,
I have a string variable str, in which the following type of values wil be stored
1) Intger
2) Long
3) boolean
4) Char
Is there any method to find out the type of the value, anything like str.getType()?. Please kindly help me. Thanks in advance.Hi All, i'm sorry for the double posting, by mistake it occured.
Thanks for your replies, i have a string variable str, in which the value is stored and i have another string variable type, in which the type of the value is stored.
For example,
String str = "15";
String type = "Integer";
Is there any way to verify whether the value stroed in str is of type stored in the variable 'type'. I want to write a method of type boolean, it will throw true of the value stored in str is of type 'type'. Thanks -
Remove Duplicates From Comma Separated String
Hi,
I have one Column which contains duplicates values with comma separated.
Customer ID
5,5,5,5,6,6,5,5,5,6,7,4,1,2,1,4,7,2
I wrote this:
select REGEXP_REPLACE('5,5,5,5,6,6,5,5,5,6,7,4,1,2,1,4,7,2', '(^|,)([^,]*)(,\2)+','\1\2') from dual;
5,6,5,6,7,4,1,2,1,4,7,2
But it eliminates only continuous elements.
I want out put like:
5,6,7,4,1,2
Please help.
Thanks.
Amit
Edited by: 987565 on Feb 12, 2013 4:02 AMThanks Purvesh,
While testing with real data, it is ignoring some values. I didn't understand why it happening.
with data as
select '5714,5714,5714,5714,5714,5714,5714,5714,5714,5714,5714,5714,5668,5716,5714,5714,5714,5714,5714,5714,5714,5714,5714,5714,5714,5714,5668,5716' col from dual
select ltrim(max(sys_connect_by_path(col, ',')) keep (dense_rank last order by rn - 1), ',') col
from (
select col, row_number() over (order by 1) rn
from (
select distinct regexp_substr(col, '[^,]+', 1, level) col
from data
connect by level <= length(col) - length(replace(col, ','))
start with rn = 1
connect by prior rn = rn - 1;
Result I got is:
5714,5714,5716
My Real Query is like that:
declare
cursor c1 is
select o.id id
from order o;
v_char varchar2(200) := '';
begin
for a1 in c1 loop
with data as
select o.cust_id as col into v_char
from order o
where o.id = a1.id
select ltrim(max(sys_connect_by_path(col, ',')) keep (dense_rank last order by rn - 1), ',') col
from (
select col, row_number() over (order by 1) rn
from (
select distinct regexp_substr(col, '[^,]+', 1, level) col
from data
connect by level <= length(col) - length(replace(col, ','))
start with rn = 1
connect by prior rn = rn - 1;
SYS.dbms_output.put_line(v_char);
end loop;
end;
Later, i will update same cust_id with v_char. -
How do I change the number format to the Indian-style comma separation?
So the default mode for Numbers is obviously the American-style comma seperation
ie. the number 123456789 will be displayed as: 123,456,789.
Does anyone know how to change this to accomodate the Indian counting system?
Specifically, to display 123456789 as 12,34,56,789.
Thanks!Default language setting for Numbers will follow your System Preferences country setting. This will determine format for decimal separator. I've never checked for the Indian format in Numbers, but if your system country setting is India, you should submit Feedback to the Numbers Team via the Numbers menu and tell them about the mistake.
Jerry -
Comma separated string in rows
Hi All,
I have one table
select * from abcd;
No err
1 rishi,rahul
2 rishi,ak
I want output like:
No ERR
1 rishi
1 rahul
2 rishi
2 ak
i am using the below query for this:
select no,regexp_substr(err,'[^,]+', 1, level) from abcd
connect by regexp_substr(err, '[^,]+', 1, level) is not null
but this query is giving me output:
1
rishi
1
rahul
2
ak
2
rishi
1
rahul
2
ak
if i am using distinct then only desired output is coming.
select distinct no,regexp_substr(err,'[^,]+', 1, level) from abcd
connect by regexp_substr(err, '[^,]+', 1, level) is not null
but i don't want to use distinct because my table has millions of rows and err contains comma separated varchar(6000);
please help me.Something like this?
SQL> ed
Wrote file afiedt.buf
1 WITH table_x AS(
2 SELECT 1 id, 'rishi,rahul' str FROM dual UNION ALL
3 SELECT 2 id, 'rishi,ak' str FROM dual
4 )
5 SELECT id,
6 REGEXP_SUBSTR (str,
7 '[^,]+',
8 1,
9 LEVEL)
10 --LEVEL,
11 --SYS_GUID ()
12 FROM table_x
13 CONNECT BY LEVEL <= LENGTH (REGEXP_COUNT (str, ',')) +1
14 AND PRIOR id = id
15 AND PRIOR Sys_Guid() IS NOT NULL
16* ORDER BY id, LEVEL
SQL> /
ID REGEXP_SUBS
1 rishi
1 rahul
2 rishi
2 ak
Trick here is: the usage of SYS_GUID() i.e. System Global Unique Identifier.
Alternative to this, can also use DBMS_RANDOM.value() here.
Read more here - https://forums.oracle.com/thread/2526535
HTH
-- Ranit -
Fastest way to count the number of occurences of string in file
I have an application that will process a number of records in a plain text file, and the processing takes a long time. Therefore, I'd like to first calculate the number of records in the file so that I can display a progress dialog to the user (e.g. " 1234 out of 5678 records processed"). The records are separated by the string "//" followed by a newline, so all I need to do to get the number of records is to count the number of times that '//' occurs in the file. What's the quickest way to do this? On a test file of ~1.5 Gb with ~500 000 records, grep manages under 5 seconds, whereas a naive Java approach:
BufferedReader bout = new BufferedReader (new FileReader (sourcefile));
String ffline = null;
int lcnt = 0;
int searchCount = 0;
while ((ffline = bout.readLine()) != null) {
lcnt++;
for(int searchIndex=0;searchIndex<ffline.length();) {
int index=ffline.indexOf(searchFor,searchIndex);
if(index!=-1) {
//System.out.println("Line number " + lcnt);
searchCount++;
searchIndex+=index+searchLength;
} else {
break;
}takes about 10 times as long:
martin@martin-laptop:~$ time grep -c '//' Desktop/moresequences.gb
544064
real 0m4.449s
user 0m3.880s
sys 0m0.544s
martin@martin-laptop:~$ time java WordCounter Desktop/moresequences.gb
SearchCount = 544064
real 0m42.719s
user 0m40.843s
sys 0m1.232sI suspect that dealing with the file as a whole, rather than line-by-line, might be quicker, based on previous experience with Perl.Reading lines is very slow. If your file has single byte character encoding then use something like the KMP algorithm on an BufferedInputStream to find the byte sequence of "//\n".getBytes(). If the file has a multi-byte encoding then use the KMP algorithm on a BufferedReader to find the chars "//\n".getCharacters() .
The basis for this can be found in reply #12 of http://forum.java.sun.com/thread.jspa?threadID=769325&messageID=4386201 .
Edited by: sabre150 on May 2, 2008 2:10 PM -
Is there an way to get the value of a local string variable from core dump?
Hi All,
Please help me on this, How to extract the string variable content from the core file.
During core file analysis using dbx, it puts value as CLASS against string local variables.
But I need to know the exact value during the core dump.
I'm able to print other than string variables.
Is this possbile using dbx or is there any other tool can help me on this.
Thanks in advance, please find the code details below:
here is my core details:
(dbx) where -h
current thread: t@74
[1] __lwp_kill(0x0, 0x6, 0x217b8, 0x7f950b94, 0x2, 0x7f0fb944), at 0x7f99fb84
[2] raise(0x6, 0x0, 0x7f0fb958, 0x7f6a5434, 0x1, 0x7f0fb9a4), at 0x7f950b9c
[3] abort(0x7f6bf0f8, 0x4, 0x7f6bf0b8, 0x15360, 0x1, 0x7f6bf0f8), at 0x7f936d10
[4] exregister(0x7f6bf0fc, 0x4, 0x7f6bf0b8, 0x15360, 0x1, 0x7f6a5048), at 0x7f6a504c
[5] exregister(0x7f6bf0f8, 0x7f6a505c, 0x7f6bf0f8, 0x7f6bb080, 0x0, 0x1), at 0x7f6a5060
[6] exregister(0x7f0fbb28, 0x66bd8, 0xe4fd0, 0x7f6bb080, 0x7f6ba780, 0x1), at 0x7f6a4fd8
[7] 0x7f6a5edc(0x7f6bae64, 0x0, 0x66bd8, 0x14cb8, 0x14928, 0x0), at 0x7f6a5edc
=>[8] AreaManager::commitCombine(this = 0xe5234, parsedSetName = CLASS), line 369 in "AreaManager.cc"
[9] TaskDispatcher::combineParsedSet(parsedSetName = CLASS), line 113 in "TaskDispatcher.cc"
[10] CombineExecutor::run(this = 0x1312d8), line 159 in "CombineExecutor.cc"
[11] thread_body(threadObj = 0x1312d8), line 35 in "ThreadUtils.cc"
(dbx)
(dbx) dump
parsedSetName = CLASS
parsedSetCombinedName = CLASS
parserSetBuiltName = CLASS
this = 0xe5234
(dbx)
(dbx) print parsedSetName
dbx: cannot access address 0x7f6690f4
(dbx)
BR//SahooWhen I was running in a higher version, it gives follwing error:
A loadobject was found with an unexpected checksum value.
When using the same core dump binary, the result are different than the locally build binary
This is the error it pointing now:
if ((ptr = (CHAR *) malloc((unsigned int) size)) == NULL)
(dbx) proc -map
Loadobject mappings for current core file:
0x00010000 /usr/omc/1.8.0.0.56/bin/PmLoader
0x7fb80000 /usr/lib/libaio.so.1
0x7fb30000 /usr/lib/libm.so.1
0x7fbfa000 /usr/lib/libdl.so.1
is being filtered by: /usr/lib/ld.so.1
Warning: checksum in file(a5bd) doesn't match image(a5bf)
0x7faf0000 /usr/lib/libelf.so.1
Warning: checksum in file(38a7) doesn't match image(38a9)
0x7fad0000 /usr/lib/libsocket.so.1
0x7fa00000 /usr/lib/libnsl.so.1
0x7f900000 /usr/lib/libc.so.1
is being filtered by: /usr/platform/SUNW,Ultra-80/lib/libc_psr.so.1
Warning: checksum in file(3b8c) doesn't match image(3ec6)
0x7f890000 /usr/informix/lib/esql/libthsql.so
0x7f830000 /usr/informix/lib/libthasf.so
0x7f7b0000 /usr/informix/lib/esql/libthgen.so
0x7f770000 /usr/informix/lib/esql/libthos.so
0x7f700000 /usr/informix/lib/esql/libifgls.so
0x7f9e0000 /usr/informix/lib/esql/libifglx.so
0x7f6d0000 /usr/lib/libthread.so.1
0x7f500000 /usr/lib/libCstd.so.1
Warning: checksum in file(1fc4) doesn't match image(3f67)
0x7f6a0000 /usr/lib/libCrun.so.1
Warning: checksum in file(1a8d) doesn't match image(b1ea)
0x7fba0000 /usr/lib/libw.so.1
is being filtered by: libc.so.1
0x7f4e0000 /usr/lib/libmp.so.2
0x7f4a0000 /usr/lib/cpu/sparcv8plus/libCstd_isa.so.1
Warning: checksum in file(0fc3) doesn't match image(27d6)
0x7f9d0000 /usr/platform/sun4u-us3/lib/libc_psr.so.1
0x7f410000 /usr/lib/nss_files.so.1
0x7fbb0000 /usr/lib/ld.so.1 [LM_ID_LDSO]
Warning: checksum in file(f2f2) doesn't match image(2a40)
dbx ./PmLoader ./core
For information about new features see `help changes'
To remove this message, put `dbxenv suppress_startup_message 7.5' in your .dbxrc
Reading PmLoader
core file header read successfully
Reading ld.so.1
Reading libaio.so.1
Reading libm.so.1
Reading libdl.so.1
Reading libelf.so.1
Reading libsocket.so.1
Reading libnsl.so.1
Reading libc.so.1
Reading libthsql.so
Reading libthasf.so
Reading libthgen.so
Reading libthos.so
Reading libifgls.so
Reading libifglx.so
Reading libthread.so.1
Reading libCstd.so.1
Reading libCrun.so.1
Reading libw.so.1
Reading libmp.so.2
Reading libCstd_isa.so.1
Reading libc_psr.so.1
Reading nss_files.so.1
WARNING!!
A loadobject was found with an unexpected checksum value.
See `help core mismatch' for details, and run `proc -map'
to see what checksum values were expected and found.
dbx: warning: Some symbolic information might be incorrect.
t@1 (l@1) terminated by signal BUS (invalid address alignment)
0x7f947974: t_delete+0x0068: clr [%o1 + 8]
Current function is Malloc
40 if ((ptr = (CHAR *) malloc((unsigned int) size)) == NULL)
(dbx)
(dbx) where -h
current thread: t@1
[1] t_delete(0x17c980, 0x470, 0x1ef778, 0x7f9bc000, 0x0, 0x0), at 0x7f947974
[2] mallocunlocked(0x414, 0x0, 0x0, 0x7f9bc000, 0x0, 0x0), at 0x7f947004
[3] malloc(0x414, 0xebae0, 0x8, 0xffbfc9a8, 0xffbfc9a0, 0x1a3791), at 0x7f946e38
=>[4] Malloc(size = 1044U), line 40 in "Malloc.c"
[5] Drain_Socket(sc = 0x1ab100, fd = 10, block = 0xffbfce44), line 1648 in "ipc_sockio.c"
[6] Sockio_Refresh(instance = 0x1ab100, fd = 10U, readable = 1, writeable = 0, block = 0xffbfce44), line 3465 in "ipc_sockio.c"
[7] do_Refresh(cid = 10U, readable = 1, writeable = 0, block = 0xffbfce44), line 1238 in "ipc_IO.c"
[8] IO_Refresh(block = 0, file_descriptor = -1), line 685 in "ipc_IO.c"
[9] ipc_receive_message(gid = 0xffbfcf88, reply = 0xffbfd080, buffer = 0x11ae08 "", len = 0xffbfcf34, block = 0), line 313 in "ipc_services.c"
[10] IPCProcessor::receiveMessage(this = 0x1172d0, channelID = 2U, pReplyChannelID = 0xffbfd080), line 312 in "IPCProcessor.cc"
[11] IPCProcessor::mainLoop(this = 0x1172d0, pHandler = 0xf9c28), line 203 in "IPCProcessor.cc"
[12] IPCService::mainLoop(pMediator = 0x1172d0, pHandler = 0xf9c28), line 51 in "IPCService.cc"
[13] main(argc = 3, argv = 0xffbfe1f4), line 91 in "PmLoader.cc"
I got another instance of core dump in same m/c
Edited by: chittusun on Nov 5, 2008 5:19 AM -
Inserting the Comma Separated Strings into Table
Hi Seniors,
i had two string and i want to insert the records in the Table COMMENT . In this way.
would u please give some programe to insert the records.
The Data and the Table
( 901,902,903,904 )
( 'hai','nice','good & mail is [email protected] ','excellent and the phone 011-235323' )
comm_id loc_id company_name comments
1 10 901 Hai
2 10 902 nice
3 10 903 good & mail is [email protected]
4 10 904 excellent and the phone 011-235323
Thanks
SeenuHi, Seenu,
In Oracle 10 (and up) you can easily split a comma-delimited list using REGEXP_SUBSTR.
INSTR and SUBSTR can do the same thing in any version, but it's more complicated.
See the general instructions below:
/* How to Split a Delimited String
This shows how to take a single row with a delimited string, such as
Animal amoeba,bat,cedusa,dodo
and transform it into multiple rows:
Animal 1 amoeba
Animal 2 bat
Animal 3 cedusa
Animal 4 dodo
PROMPT ========== -1. sep_char parameter ==========
VARIABLE sep_char VARCHAR2 (10)
EXECUTE :sep_char := ',';
SELECT :sep_char AS sep_char
FROM dual;
PROMPT ========== 0. string_test table ==========
DROP TABLE string_test;
CREATE TABLE string_test
( grp_name VARCHAR2 (10)
, list_txt VARCHAR2 (50)
INSERT INTO string_test (grp_name, list_txt) VALUES ('Animal', 'amoeba,bat,cedusa,dodo');
INSERT INTO string_test (grp_name, list_txt) VALUES ('Date', '15-Oct-1582,16-Oct-2008');
INSERT INTO string_test (grp_name, list_txt) VALUES ('Nothing', NULL);
INSERT INTO string_test (grp_name, list_txt) VALUES ('Place', 'New York');
INSERT INTO string_test (grp_name, list_txt) VALUES ('Skip', 'Hop,,Jump');
SELECT *
FROM string_test
ORDER BY grp_name;
PROMPT ========== Q1. Oracle 11 Query ==========
WITH cntr AS -- Requires Oracle 9
( -- Begin sub-query cntr, to generate n (1, 2, 3, ...)
SELECT LEVEL AS n -- Requires Oracle 9
FROM dual
CONNECT BY LEVEL <= 1 + (
SELECT MAX ( REGEXP_COUNT (list_txt, :sep_char) ) -- Requires Oracle 11
FROM string_test
) -- End sub-query cntr, to generate n (1, 2, 3, ...)
SELECT grp_name
, n
, REGEXP_SUBSTR ( list_txt -- Requires Oracle 10
, '[^' || :sep_char || ']' -- Anything except sep_char ...
|| '+' -- ... one or more times
, 1
, n
) AS item_txt
FROM string_test
JOIN cntr -- Requires Oracle 9
ON n <= 1 + REGEXP_COUNT (list_txt, :sep_char) -- Requires Oracle 11
ORDER BY grp_name
, n;
/* Notes:
REGEXP_SUBSTR (s, '[^,]+', 1, n)
returns the n-th item in a comma-delimited list s.
If there are fewer than n items, it returns NULL.
One or more consecutive characters other than comma make an item, so
'Hop,,Jump' has two items, the second one being 'Jump'.
The sub-query cntr produces a list of integers 1, 2, 3, ..., w
where w is the worst-case (the largest number of items in any list).
This actually counts separators, not items, (e.g., it counts both
commas in 'Hop,,Jump', even though), so the w it produces may be
larger than is really necessary. No real harm is done.
PROMPT ========== Q2. Possible Problems Fixed ==========
WITH cntr AS
( -- Begin sub-query cntr, to generate n (1, 2, 3, ...)
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= 1 + (
SELECT MAX ( REGEXP_COUNT (list_txt, :sep_char) )
FROM string_test
) -- End sub-query cntr, to generate n (1, 2, 3, ...)
SELECT grp_name
, n
, REGEXP_SUBSTR ( list_txt
, '[^' || :sep_char || ']' -- Anything except sep_char ...
|| '+' -- ... one or more times
, 1
, n
) AS item_txt
FROM string_test
JOIN cntr ON n <= 1 + NVL ( REGEXP_COUNT (list_txt, :sep_char) -- Problem (1)
, 0
WHERE REGEXP_SUBSTR ( list_txt -- Problem (2)
, '[^' || :sep_char || ']' -- Anything except sep_char ...
|| '+' -- ... one or more times
, 1
, n
) IS NOT NULL
OR list_txt IS NULL -- Problems (1) and (2) together
ORDER BY grp_name
, n;
(Possible) Problems and Fixes
(1) If list_txt IS NULL, then REGEXP_COUNT (list_txt, :sep_char)
returns NULL, the join condition fails, and the output
contains nothing corresponding to the row from string_test.
If you want a NULL item to appear in the results, use
NVL to make sure the expression returns 0 instead of NULL.
(2) If list_txt contains multiple consecutive sep_chars (or if it
begins or ends with sep_char, then the original query
will return NULL items. To suppress these, add a WHERE
clause to test that the item_txt to be displayed IS NOT NULL.
PROMPT ========== Q3. Oracle 8.1 Query ===========
SELECT grp_name
, n
, SUBSTR ( list_txt
, begin_pos
, end_pos - begin_pos
) AS item_txt
FROM ( -- Begin sub-query to compute begin_pos and end_pos
SELECT grp_name
, n
, list_txt
, INSTR ( :sep_char || list_txt
, :sep_char
, 1
, n
) AS begin_pos
, INSTR ( list_txt || :sep_char
, :sep_char
, 1
, n
) AS end_pos
FROM string_test
, ( -- Begin sub-query cntr, to generate n (1, 2, 3, ...)
SELECT ROWNUM AS n
FROM all_objects
WHERE ROWNUM <= 1 + (
SELECT MAX ( LENGTH (list_txt)
- LENGTH (REPLACE (list_txt, :sep_char))
FROM string_test
) -- End sub-query cntr, to generate n (1, 2, 3, ...)
cntr
WHERE n <= 1 + ( LENGTH (list_txt)
- LENGTH (REPLACE (list_txt, :sep_char))
) -- End sub-query to compute begin_pos and end_pos
ORDER BY grp_name
, n;
/* Version-Dependent Features and Work-Arounds
The code above, Q3, runs in Oracle 8.1.
The following changes were made to Q1:
(11) REGEXP_COUNT was introduced in Oracle 11.
In earlier versions, to find the number of sep_chars in list_txt,
see how much the LENGTH changes when sep_chars are removed.
(10) REGEXP_SUBSTR was introduced in Oracle 10.
In earlier versions, use INSTR to find where the sep_chars are,
and use SUBSTR to get the sub-strings between them.
(Using this technique, 'Hop,,Jump' still contains three items,
but now item 2 IS NULL and item 3 is 'Jump'.)
(9.a) The WITH-clause was introduced in Oracle 9
In earlier versions, use in-line views.
(9.b) "CONNECT BY LEVEL < constant" doesn't work in Oracle 8.
Use ROWNUM from any sufficiently large table or view instead.
(9.c) ANSII join notation (JOIN table_name ON ...) was introduced in Oracle 9
In earlier versions, join condition go in a WHERE-clause.
*/
Maybe you are looking for
-
Oracle 9i Error in invoking target ntcontab.o of makefile
Does anybody know what this means / how to get the install to continue (I am using Mandrake 8.1) I am new both to Oracle and Linux, help to finally get this installed would be much appreciated.
-
Is it possible to send a Workitem to Outlook??
Hi, I know we can send a notification mail to Microsoft Outlook. I have this requirement for PO Release workflow. the user wants to have a workitem in Outlook inbox. Can we send a workitem to Outlook inbox? I am working in ECC 6.0. Thanks Jayanthi.K
-
when i am syncing all my music and videos it isn't putting them all there like it will only put 974 songs out of 5250 items any idears that would fix and i have already tried restoreing it too
-
Hi everybody! I would like to call custom view (copied from standard view). 1. Copied view "IRecPartner" into application Z_CRM_IC. 2. Defined custom IC Web Client & IC Web Client Runtime framework profiles. 3. Defined navigational link through appli
-
How to install the OWB patch 2864550
hi, friends, i am a newbie to OWB. can u tell me how to install the owb patch 2864550? it seems that this patch is not like other oracle patchs which consists of the products.jar that can be used by the oracle installer. thx