|
-
string processing help
I am trying to write a procedure to Cut the string and insert the values into a table. But not able to really succeed.
Can somebody help me in improvising this code.
ServerString is like
data1;data2;data3,data01;;data03
(each row separated by , and column data separated by ; )
This string should go into table as:
PHP Code:
col1 col2 col3
-------------------------------
data1 data2 data3
data01 data03
Create or replace procedure ProcessString (ServerString IN Varchar2)
Is
v_serverId Server_Detail.Server_Id%type;
Cursor get_vals is Select
regexp_substr(astring,'[^;]+',1,1) v1,
regexp_substr(astring,'[^;]+',1,2) v2,
regexp_substr(astring,'[^;]+',1,3) v3,
regexp_substr(astring,'[^;]+',1,4) v4,
regexp_substr(astring,'[^;]+',1,5) v5,
regexp_substr(astring,'[^;]+',1,6) v6
from (select ServerString astring from dual);
Begin
for a in get_vals loop
Begin
dbms_output.put_line('1 value:'||a.v1);
dbms_output.put_line('2 value:'||a.v2);
dbms_output.put_line('3 value:'||a.v3);
dbms_output.put_line('4 value:'||a.v4);
dbms_output.put_line('5 value:'||a.v5);
End;
end loop;
End;
Last edited by Sonia; 07-28-2010 at 08:53 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|