I have an Oracle PL/SQL routine that takes a BLOB as a parameter. The BLOB contains a .jpg file. I want to assign the BLOB parameter to a local variable. I then want to insert (or update) a BLOB column in a table the BLOB varaible.
I have tried something like this:
declare
vATTACHMENT blob;
begin
dbms_lob.createtemporary(vATTACHMENT, false, dbms_lob.session);
dbms_lob.write(vATTACHMENT, dbms_lob.lobmaxsize, 1, :pATTACHMENT));
-- do some stuff
insert into attachments (attachment, file_name)
values (vATTACHMENT, vFILE_NAME);
end;
But I get the following error:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "SYS.DBMS_LOB", line 811
ORA-06512: at line 21
I have also tried a direct assignment like vATTACHMENT := :pATTACHMENT; but that doesn’t want to work either.
I think you can use
DEFAULTin a variable declaration to assign a value to it without using the assignment operator:=, e.g.: