Here is my stored procedure:
CREATE OR REPLACE PACKAGE BS_SAMPLES AS
TYPE type_memo_raw IS TABLE OF LONG RAW;
PROCEDURE MIGRATE_MEMO_TO_MEMO_CLOB(RMEMO OUT type_memo_raw);
END BS_SAMPLES;
CREATE OR REPLACE PACKAGE BODY BS_SAMPLES AS
PROCEDURE MIGRATE_MEMO_TO_MEMO_CLOB (RMEMO OUT type_memo_raw)
AS
ls_memo_raw type_memo_raw;
BEGIN
SELECT MR.MEMO_DATA BULK COLLECT
INTO ls_memo_raw
FROM V3_TO_V4_MEMO A, MEMO_RTF MR
WHERE A.MEMO_ID = MR.MEMO_ID;
RMEMO :=ls_memo_raw;
End MIGRATE_MEMO_TO_MEMO_CLOB;
END BS_SAMPLES;
When I try to execute the Procedure, I am getting the following error:
ORA - 06502:PL/SQL : Numeric or Value Error:Bulk Bind : truncated Bind
Using Oracle version: Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
Table Memo_rtf
Name Null Type
MEMO_ID NOT NULL NUMBER(10)
MEMO_DATA LONG RAW()
Table V3_TO_V4_MEMO
Name Null Type
MEMO_ID NUMBER(10)
There is a difference between LONG ROW in PL/SQL and SQL.
In SQL:
http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm
"Raw binary data of variable length up to 2 gigabytes."
In PL/SQL:
http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/datatypes.htm#i10924
" You use the LONG RAW datatype to store binary data or byte strings. LONG RAW data is like LONG data, except that LONG RAW data is not interpreted by PL/SQL. The maximum size of a LONG RAW value is 32760 bytes. "
See example below:
SQL> desc t
Имя Пусто? Тип
----------------------------------------- -------- ----------------------------
X LONG RAW
CREATE OR REPLACE PACKAGE BS_SAMPLES AS
TYPE type_memo_raw IS TABLE OF LONG RAW;
PROCEDURE MIGRATE_MEMO_TO_MEMO_CLOB(RMEMO OUT type_memo_raw);
END BS_SAMPLES;
CREATE OR REPLACE PACKAGE BODY BS_SAMPLES AS
PROCEDURE MIGRATE_MEMO_TO_MEMO_CLOB (RMEMO OUT type_memo_raw)
AS
ls_memo_raw type_memo_raw;
BEGIN
SELECT t.x BULK COLLECT
INTO ls_memo_raw
FROM t;
RMEMO := ls_memo_raw;
End MIGRATE_MEMO_TO_MEMO_CLOB;
END BS_SAMPLES;
OK, now I added 1 row to T table and put into X column the image (using PL/SQL Developer tool) what has about 90K size.
SQL> declare
2 a BS_SAMPLES.type_memo_raw;
3 begin
4 BS_SAMPLES.MIGRATE_MEMO_TO_MEMO_CLOB(a);
5 end;
6 /
declare
*
error in line 1:
ORA-06502: PL/SQL: : Bulk Bind: Truncated Bind
ORA-06512: at "SCOTT.BS_SAMPLES", line 7
ORA-06512: at line 4
SQL> alter table t modify (x blob);
SQL> select dbms_lob.getlength(x) a from t;
a
------------------------------
90025
Ok, let's now re-create table T and add the image with about 29K size - all will work:
SQL> declare
2 a BS_SAMPLES.type_memo_raw;
3 begin
4 BS_SAMPLES.MIGRATE_MEMO_TO_MEMO_CLOB(a);
5 end;
6 /
PL/SQL procedure completed.
SQL> alter table t modify (x blob);
SQL> select dbms_lob.getlength(x) a from t;
a
------------------------------
25554
So LONG ROW should be converted to BLOB and this is the best way to handle it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With