I want to extract BLOB data and write a file (suggest it should be excel or txt or any other) out of it. A single cell has upto 60k characters. I wanted to write a script that reads whole table with BLOB data and write into a file. In below code ROWNUM works only for one row. what's the alternative? Or is there another script that can help me to achieve my ultimate objective to read BLOB and write file?
SET SERVEROUTPUT ON;
DECLARE
TotalRows NUMBER;
TotalChar NUMBER;
CharCounter NUMBER;
BEGIN
SELECT count(*) INTO TotalRows FROM <TableName>;
--dbms_output.Put_line(RC);
--END;
FOR RC IN 1..TotalRows
LOOP
-----------------Code for Rows starts--------------------------------------------------------------------------------
dbms_output.Put_line('Row '||RC||' Started.');
SELECT Length(<ColumnWithBLOBDataType>) INTO TotalChar FROM <TableName> where **Rownum = RC**;
dbms_output.Put_line('Crossed Char counting query. TotalChar='||TotalChar);
CharCounter:=TotalChar/2000+1;
dbms_output.Put_line('Loop will run these many times= '||CharCounter|| ' and Total Chars=' ||TotalChar);
For CC IN 1..CharCounter
LOOP
dbms_output.Put_line('Trip: '||CC);
END LOOP;
-----------------Code for Rows Ends----------------------------------------------------------------------------------------
TotalChar :=0;
dbms_output.Put_line('Row '|| RC||' Done. TotalChar='|| TotalChar);
END LOOP;
dbms_output.Put_line('Exited loop 1.');
END;