ora-01406 Error when fetching values using OCI

我只是一个虾纸丫 提交于 2019-12-13 00:49:15

问题


This occurs when fetching values which have a max length of 50, to a buffer which could only hold 30 chars.

I've already looked up the error and found a possible solution, which is to expand the size of the buffer which the value is bound to.

The problem is, this occurs only in some of our systems and not in others. Does the Oracle version have anything to do with this? If so, what is the version in which this error has been changed?

The Oracle versions we use are 10.2.0.1 and 10.2.0.3


回答1:


The bug listed in the question has been fixed in 10.2.0.3 and The error is only given in Oracle versions prior to that. Edit: The same issue was seen in Oracle 10.2.0.4. We're still looking in to this

Edit2: When defining cursors for CHAR/VARCHAR columns in OCI (we use a wrapper for this purpose), the size of the string which is bound to a column must be at least one greater than the maximum width of the column.

e.g. Column Name: U_NAME Type: VARCHAR(30)

1. char zName[30]; pCursor->Define(zName, 3O); // this would crash if the column has a value with 30 chars

2. char zName[31]; pCursor->Define(zName, 3O); // this would crash if the column has a value with 30 chars

3. char zName[31]; pCursor->Define(zName, 31); // Correct. would not crash for any value




回答2:


You have a bug in your code, in that it only allows for 30 chars when it may receive 50. Why not just fix it rather than worry about which Oracle version the bug causes issues with?



来源:https://stackoverflow.com/questions/1458881/ora-01406-error-when-fetching-values-using-oci

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!