Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Null in a character array

439846Mar 8 2005 — edited Mar 9 2005
We have developed an interface to write the Fortran calculated data into the Oracle database using PRO-C.(both in Oracle 9i and 10g)

We are using Compaq Visual Fortran 6.6 version for this.

We have one problem in writing the binary data into oracle database. We are converting the data array of real numbers to binary data before
writing into database. In this binary conversion process, null character appears in the middle, for some numbers (as ASCII value for 0 is null) . As C strings are
terminated by null character, whenever the character array encounters the null, only the character array till the first null character
are written in the database. For example, the data array of 50 real numbers are converted to character array of length 200 (50 * 4 bytes), null character appears at 62nd byte.
Hence, only the character array of length 61 is being written in the database, instead of character array of length 200. Valid binary data exist form 63rd byte onwards.

In the MSDN help we found the following information.
---------------------------------------------------
character data can be held in a non-null terminated array and its byte length passed separately, it is possible to embed null characters in character data. However, the behavior of ODBC functions in this case is undefined and it is driver-specific whether a driver handles this correctly. Thus, interoperable applications should always handle character data that can contain embedded null characters as binary data.

------------------------------------------------------

Is it possible to tell the compiler to handle the character array with embedded null character without termination ? (i.e) if the character array is defined as 200, then the PRO-C function should write the
complete 200 byte of data and should not get terminated in the middle.



Thanks,
Regards

Vinay
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 6 2005
Added on Mar 8 2005
4 comments
203 views