|
-
Since the data string has embedded spaces that separate values you could use the INSTR() function from within a PL/SQL block to 'parse' the string into separate fields. As an example:
declare
pos number:=0;
next_pos number:=0;
len number:=0;
var1 varchar2(40);
var2 varchar2(40);
var3 varchar2(40);
var4 varchar2(40);
cursor get_string is
select string
from string_table;
begin
for strng in get_string loop
next_pos := instr(strng.string, ' ', pos+1, 1);
len := next_pos - pos - 1;
var1 := substr(strng.string, pos + 1, len);
pos := next_pos;
next_pos := instr(strng.string, ' ', pos+1, 1);
len := next_pos - pos - 1;
var2 := substr(strng.string, pos + 1, len);
pos := next_pos;
next_pos := instr(strng.string, ' ', pos+1, 1);
len := next_pos - pos - 1;
var3 := substr(strng.string, pos + 1, len);
pos := next_pos;
next_pos := instr(strng.string, ' ', pos+1, 1);
if next_pos = 0 then
var4 := substr(strng.string, pos+1);
else
len := next_pos - pos - 1;
var4 := substr(strng.string, pos + 1, len);
end if;
insert into var_table
values
(var1, var2, var3, var4);
commit;
pos := 0;
end loop;
end;
/
Hopefully this will give you some idea of how to proceed.
David D. Fitzjarrell
Oracle Certified DBA
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
|