Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORA - 06502:PL/SQL : Numeric or Value Error:Bulk Bind : truncated Bind

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) 
like image 315
7783 Avatar asked Jan 19 '26 05:01

7783


1 Answers

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.

like image 178
Dmitry Nikiforov Avatar answered Jan 20 '26 22:01

Dmitry Nikiforov