problem with storing raw data in long raw datatype by using utl_file
912042Jan 19 2012 — edited Jan 30 2012HI I am trying to open the file in read binary mode and i specified the maximum size is 500 bytes .
After getting the raw data i tried to concat with var2 variable (long raw datatype) .
at last var2 variable i try store in table temp_test_raw_tbl ( contains only one column which is LONG RAW);
but i raising error
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
i am thinking the reason behind this error is bcz of size of var2 is not sufficient
how can i store store that file in raw data format
declare
file_pointer utl_file.file_type;
VAR RAW(32767);
VAR2 LONG RAW;
begin
file_pointer := utl_file.fopen(location => 'IMAGES',FILENAME => '12.JPG',OPEN_MODE =>'RB',max_linesize => 500);
begin
WHILE TRUE
LOOP
UTL_FILE.get_raw(FILE => FILE_POINTER,BUFFER => VAR,len=>500) ;
DBMS_OUTPUT.PUT_LINE(1);
VAR2:=VAR2||VAR;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
end;
UTL_FILE.FCLOSE(FILE_POINTER);
insert into temp_test_raw_tbl
values(var2);
dbms_output.put_line(sql%rowcount);
commit;
end ;