tags:

views:

668

answers:

2

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

A: 

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?

Tony Andrews
We will be fixing it. But in a production environment not being able to recreate a bug is a critical issue which should be addressed and resolved in order to prevent such errors from occurring again.This has been filed as a bug in Oracle (bug 4546618) which leads to further confusion as to where exactly the fix should take place.Fixing the bug is important but we're more concerned with prevention in the long run
Gayan
OK, but I'm curious: what does Oracle 10.2.0.3 do now - silently truncate the value to 30 chars? I would have that that was worse?
Tony Andrews
The problem lies in the fact that I'm giving the length of the string when I'm defining values for the cursor. Sorry about not mentioning this in the original question. Anyway, the value in the database should get truncated to this length, which doesn't seem to happen in 10.2.0.1.
Gayan
+1  A: 

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

Gayan