`

SELECT containing a MIN or MAX into a CHAR variable inside a PL/SQL block Fails

阅读更多
简单描述下:主机HP 11.31  数据库ORACLE 9205 升级到10205
星期天,对一个库进行了升级;升级完,应用运行时,出现
ORA-06502:PL/SQL:数字或值错误,字符串缓冲区太小
经分析,可能是原应用程序的SQL代码使用了CHAR导致
METLINK上解释如下:

SELECT containing a MIN or MAX into a CHAR variable inside a PL/SQL block Fails With ORA-06502 [ID 311653.1] 

Applies to:
Oracle Server - Enterprise Edition - Version: 10.1.0.4 to 10.1.0.4
Oracle Server - Enterprise Edition - Version: 9.2.0.6 to 9.2.0.7
Oracle Server - Enterprise Edition - Version: 10.2.0.1 to 10.2.0.1
This problem can occur on any platform.
Symptoms

SELECT containing a MIN or MAX into a CHAR variable inside a PL/SQL block Fails With:

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

Example:


DECLARE
C CHAR(1);
BEGIN
SELECT MIN('Y') INTO C FROM dual;
END;
/


DECLARE
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 4

Changes

    * After upgrading to Oracle10gR2 10.2.0.1
    * After applying 10.1.0.4 patchset
    * After applying 9.2.0.6 patchset
    * After applying 9.2.0.7 patchset

Cause
This problem has been identified as

Bug:4458790 ORA-6502 selecting MAX/MIN into a CHAR variable in PLSQL

This problem is introduced in Oracle9i 9.2.0.6, Oracle10g 10.1.0.4 and 10.2.0.1 by the fix for Bug:3499258.

A PLSQL block which SELECTs a MAX or MIN into a fixed CHAR variable can fail with an unexpected ORA-6502 "character string buffer too small" error.
Solution

This problem is fixed in

    * Oracle9iR2 (9.2.0.8, terminal patchset)
    * Oracle11gR1(11.1.0.x or higher)
    * Oracle10gR1(10.1.0.5 or higher)
    * Oracle10gR2 (10.2.0.2 or higher)

Workarounds:

    * setting initialisation parameter BLANK_TRIMMING=TRUE

    * declare PL/SQL CHAR and VARCHAR2 variable used in the INTO clause of SELECT statement as 4,000 bytes.

    * Use CAST SQL function to constraint the size to that of the variable size like

      SELECT CAST(MIN('Y') AS CHAR(1)) INTO C FROM DUAL;

References
BUG:3499258 - SQL FUNCTION FOR CHAR DATA RETURNS AS VARCHAR IN PL/SQL
BUG:4308587 - SELECT MIN / MAX FROM A CHAR VALUE RETURNS ORA-6502 IN PL/SQL
BUG:4458790 - ORA-6502 HAPPENS IN SELECT MIN FROM CHAR
PATCH:4458790 - ORA-6502 HAPPENS IN SELECT MIN FROM CHAR
分享到:
评论

相关推荐

    Oracle sqldeveloper without jdk (win+linux)

    - Bug # 4918539: ORA-ORA-06502 or ORA-01460 may occurs if a procedure is executed through the Run PL/SQL dialog box and a string with multibyte characters is assigned to one of the parameters. ...

    微软内部资料-SQL性能优化3

    Used to lock ranges between records in a table to prevent phantom insertions or deletions into a set of records. Ensures serializable transactions. RID A Row Identifier. Used to individually lock a ...

    SQLPrompt_9.5.0.9311破解版

    SP-7522 : Fixed an issue of incorrect wildcard expansion from a nested SELECT containing CASE. SP-7545 : Fixed an issue where aliases were not being suggested within nested scopes. Fixed an issue ...

    微软内部资料-SQL性能优化5

    On a qualified select, update, or delete, the correct leaf page will be the lowest page of the tree in which one or more rows with the specified key or keys reside. A qualified operation is one that ...

    解决Tensorflow2.0 tf.keras.Model.load_weights() 报错处理问题

    4、模型报错:ValueError: You are trying to load a weight file containing 12 layers into a model with 0 layers. 问题分析: 模型创建后还没有编译,一般是在模型加载前调用model.build(input_shape), 但我通过...

    微软内部资料-SQL性能优化2

    A hard page fault results in a read from disk, either a page file or memory-mapped file. A soft page fault is resolved from one of the modified, standby, free or zero page transition lists. Paging is...

    SQLPrompt_7.3.0.651(包含注册机)

    Fix for formatting failling with SELECT into variable with += (Forum post) 7.3.0.564 - 22nd September Fix for formatting failing on some scripts (Forum post) Option for adding spaces around ...

    php.ini-development

    E_ALL & ~E_NOTICE), a quoted string ("bar"), or a reference to a ; previously set variable or directive (e.g. ${foo}) ; Expressions in the INI file are limited to bitwise operators and parentheses: ...

    2009 达内Unix学习笔记

    [] 匹配中括号里的内容[a-z][A-Z][0-9]。 ! 事件。 $ 取环境变量的值。 | 管道。把前一命令的输出作为后一命令的输入,把几个命令连接起来。 |经常跟tee连用,tee 把内容保存到文档并显示出来。 三、通用后...

    squashfs2.2-r2.tar.gz

    files which do not fit fully into a block, are NOT by default packed into fragments. To illustrate this, a 100K file has an initial 64K block and a 36K remainder. This 36K remainder is not packed into...

    squashfs1.3r3.tar.gz

    This can either be a conventional file or a block device. If the file doesn't exist it will be created, if it does exist and a squashfs filesystem exists on it, mksquashfs will append. The -noappend ...

    A&H IDR-8音频处理器说明

    containing the main iDR unit, or, similarly, the iDR-Out could be configured as a four-way-stereo XLR output to an amp rack located at the side of a theatre stage. Furthermore, the 8-buss link can be ...

    Variable-length Codes for Data Compression

    However, there are a large number of less-known codes that have useful properties - such as those containing certain bit patterns, or those that are robust - and these can be useful. This book brings...

    sql odbc 12.rar

    Microsoft ODBC Driver 17 for SQL Server is a single dynamic-link library (DLL) containing run-time support for applications using native-code APIs to connect to Microsoft SQL Server 2008, SQL Server ...

    Dev2000_Build_Forms_I_Student_Guide_vol01

    Developer/2000, Oracle Server, PL/SQL are trademarks or registered trademarks of Oracle Corporation. All other products or company names are used for identification purposes only, and may be ...

    Synthesis, Characterization, and Reactivity of Cationic Palladium(II) and Platinum(II) Iodo Complexes Containing a Linear or a Tripodal Aminophosphine. The X-Ray Crystal Structures of [Pd{HN(CH2CH2PPh2)2}I]I and [Pd3{N(CH2CH2PPh2}3)2I4]I2

    Synthesis, Characterization, and Reactivity of Cationic Palladium(II) and Platinum(II) Iodo Complexes Containing a Linear or a Tripodal Aminophosphine. The X-Ray Crystal Structures of [Pd{HN(CH2CH2PPh...

    基于dijkstra的低耗路由matlab仿真

    [AorV] Either A or V where A is a NxN adjacency matrix, where A(I,J) is nonzero if and only if an edge connects point I to point J NOTE: Works for both symmetric and asymmetric A V is a Nx2 (or ...

    commons-dbcp-1.4-src&commons-pool-1.5.4-src

    This is a patch release containing a fix for POOL-152, a regression introduced in version 1.5. Changes in this version include: Fixed Bugs: o POOL-152: GenericObjectPool can block forever in ...

    Hive - A Warehousing Solution Over a Map-Reduce.pdf

    queries expressed in a SQL-like declarative language - HiveQL, which are compiled into map-reduce jobs executed on Hadoop. In addition, HiveQL supports custom map-reduce scripts to be plugged into ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    There are some common exceptions, such as unittests and small .cc files containing just a main() function. Correct use of header files can make a huge difference to the readability, size and ...

Global site tag (gtag.js) - Google Analytics