jytr
asked on
Reading the content of a CLOB column
hi all, I uploaded a file to a CLOB column , i would need:
1. to know how I can know if the file has been actually inserted into the column: where / what I have to go / do in order to see if there is some content?
2. I need procedure code to read the content of the CLOB column
Please send just code that actually works and please indicate steps by steps what I have to do to launch the procedure as, even tought I use it, I am not an Oracle procedure and programmig expert ...
Thank you and regards
1. to know how I can know if the file has been actually inserted into the column: where / what I have to go / do in order to see if there is some content?
2. I need procedure code to read the content of the CLOB column
Please send just code that actually works and please indicate steps by steps what I have to do to launch the procedure as, even tought I use it, I am not an Oracle procedure and programmig expert ...
Thank you and regards
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi konektor, please try your procedure as I get an error...at the line of the if ...it tells me 'ORA-06550: line 7, column 3:
PL/SQL: ORA-00933: SQL command not properly ended'
thanks and regards
PL/SQL: ORA-00933: SQL command not properly ended'
thanks and regards
because you need to put in your own where clause, and not just cut and paste the procedure.
select lob_col into v_lob_col from your_table where condition...
is not a valid SQL statement, because there is no condition for the where clause. you need something like
primary_key_col = your_primary_key instead of "condition..."
select lob_col into v_lob_col from your_table where condition...
is not a valid SQL statement, because there is no condition for the where clause. you need something like
primary_key_col = your_primary_key instead of "condition..."
create procedure read_clob
is
clobColumn clob;
iClobSize integer;
rBuffer raw(32767);
vBuffer varchar2(32767);
nOffset number := 1;
iMaxSize integer := 32767;
iChunkSize integer;
iLeftOver integer;
begin
dbms_lob.createTemporary(c lobColumn, true);
--select lob_col into clobColumn from your_table where....
iClobSize := dbms_lob.getlength(clobCol umn);
if iClobSize > 0
then
loop
iLeftOver := (iClobSize - nOffset + 1);
if iLeftOver <= iMaxSize
then
iChunkSize := iLeftOver;
else
iChunkSize := iMaxSize;
end if;
dbms_lob.read(clobColumn, iChunkSize, nOffset, rBuffer);
vBuffer := utl_raw.cast_to_varchar2(r Buffer);
--processing....
nOffset := nOffset + iMaxSize;
if nOffset > iClobSize
then
exit;
end if;
end loop;
end if;
dbms_lob.freeTemporary(clo bColumn);
end read_clob;
/
is
clobColumn clob;
iClobSize integer;
rBuffer raw(32767);
vBuffer varchar2(32767);
nOffset number := 1;
iMaxSize integer := 32767;
iChunkSize integer;
iLeftOver integer;
begin
dbms_lob.createTemporary(c
--select lob_col into clobColumn from your_table where....
iClobSize := dbms_lob.getlength(clobCol
if iClobSize > 0
then
loop
iLeftOver := (iClobSize - nOffset + 1);
if iLeftOver <= iMaxSize
then
iChunkSize := iLeftOver;
else
iChunkSize := iMaxSize;
end if;
dbms_lob.read(clobColumn, iChunkSize, nOffset, rBuffer);
vBuffer := utl_raw.cast_to_varchar2(r
--processing....
nOffset := nOffset + iMaxSize;
if nOffset > iClobSize
then
exit;
end if;
end loop;
end if;
dbms_lob.freeTemporary(clo
end read_clob;
/
http://www.psoug.org/reference/dbms_lob.html