Have you ever been faced to the above error? I mean this bizarre Bulk Bind: Truncated Bind? This is a strange and unclear error message. Let me put you in the context that gave me this error. I am trying to load data into an 11gR2 (11.2.0.3.0) database from data coming via a db link from a 10gR2 (10.2.0.5.0). This is not more as what I have simplified to the maximum here below
11gR2> begin 2 for x in ( 3 select v2_col 4 from distant_table 5 ) 6 loop 7 null; 8 end loop; 9 end; 10 / begin * ERROR at line 1: ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind ORA-06512: at line 2
And if instead I issue a straightforward select from a SQL windows
11gR2> select v2_col from distant_table;
I have no errors.
I was struggling with this issue until one of my smart colleagues puts me into the right direction: there is a difference in the character set between the 11g (multi-byte) and the 10g database (single byte) as shown below
11gR2> select * from nls_database_parameters; PARAMETER VALUE ------------------------------ ---------------------------- NLS_CHARACTERSET AL32UTF8 --> here multibyte NLS_LENGTH_SEMANTICS CHAR --> here NLS_NCHAR_CHARACTERSET AL16UTF16 NLS_RDBMS_VERSION 11.2.0.3.0 10gR2> select * from nls_database_parameters; PARAMETER VALUE ------------------------------ ------------------------------------ NLS_CHARACTERSET WE8ISO8859P1 --> here single byte NLS_LENGTH_SEMANTICS BYTE --> here NLS_NCHAR_CHARACTERSET AL16UTF16 NLS_RDBMS_VERSION 10.2.0.5.0
I was thinking that the 11gR2 PL/SQL engine (because still I am not fetching anything explicitly, I am just selecting) could recognize this character set difference between the local and the distant database and implicitly declare its local variable so that it could have enough space to contain incoming column when this one will have special characters .
Having smart colleagues is always a lucky situation, because not only my colleague pointed me to the right direction but gave me a workaround that I am pleased to reproduce here below :
11gR2> begin 2 for x in ( 3 select v2_col ||'' 4 from distant_table 5 ) 6 loop 7 null; 8 end loop; 9 end; 10 / PL/SQL procedure successfully completed.
The work around consists of concatenating the distant column v2_col with a null string. This magically overcome the Bulk Bind: Truncated Bind error (don’t tell me why the PL/SQL engine can overcome this error when I have used such a concatenation).
If you have already been faced to this error then I will be pleased to know how you managed to solved it
