Hi vincent,
Sorry, mistake for copy the source,it become this error code
char buffer;
OCI_File file = OCI_GetFile(rs, index);
CHECK_ERR(OCI_FileOpen(file));
int size = OCI_FileGetSize(file);
char data = new char;
Using size OR size + 1, also face the same problem.
For Oracle Database Express Edition 10g Release 2 (10.2),
It can't exit the While loop. The "n" alway return buffer size (256-1)
For Oracle 9i, It hit error on delete data; --- HEAP CORRUPTION DETECTED:
after %hs block
Will try it again, next monday at company for Oracle 9i.
Environment:
OCI_CHARSET_WIDE
Window XP
Regards
Teh
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
remember that OCI_FileRead () reads binary data like fread().
It does not add a terminal '\0'. So using that buffer with strcat and strcpy
is wrong if you don't set yourself the trailing '\0'
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Vincent,
I use the below code to retreive the data, as provide from http://orclib.sour
ceforge.net/doc/html/group__g__file.html
The cause an error when clear the memory . Please help.
What is the difference bewteen OCI_CFILE and OCI_BFILE ?
What Oracle datatype is mapping to OCI_CFILE or when to use OCI_CFILE for
retreive the data ?
Regards
Alvin
CREATE TABLE my_bfile_table( code NUMBER, value BFILE);
char buffer;
OCI_File file = OCI_GetFile(rs, index);
CHECK_ERR(OCI_FileOpen(file));
int size = OCI_FileGetSize(file);
char data = new char;
int n;
while (n = OCI_FileRead(file, buffer, sizeof(buffer)-1))
{
buffer = '\0';
if (strlen(data) == 0)
strcpy(data,buffer);
else
strcat(data,buffer);
}
OCI_FileClose(file);
-- process .. (no doing anything)
delete data; --- HEAP CORRUPTION DETECTED: after %hs block
Hi,
In fact OCI_CFILE and OCI_BFILE are the same.
OCI folks created this distinction but never used it.
in the code, check that strcat does not do buffer overwrite. Check the buffer
length
regards
vincent
hum, got some trouble with the bbcode formatting
use size+1 instead of size in your array allocation
Hi vincent,
Sorry, mistake for copy the source,it become this error code
char buffer;
OCI_File file = OCI_GetFile(rs, index);
CHECK_ERR(OCI_FileOpen(file));
int size = OCI_FileGetSize(file);
char data = new char;
Using size OR size + 1, also face the same problem.
For Oracle Database Express Edition 10g Release 2 (10.2),
It can't exit the While loop. The "n" alway return buffer size (256-1)
For Oracle 9i, It hit error on delete data; --- HEAP CORRUPTION DETECTED:
after %hs block
Will try it again, next monday at company for Oracle 9i.
Environment:
OCI_CHARSET_WIDE
Window XP
Regards
Teh
Testing for correct : new char with size
char *data = new char;
remember that OCI_FileRead () reads binary data like fread().
It does not add a terminal '\0'. So using that buffer with strcat and strcpy
is wrong if you don't set yourself the trailing '\0'
Hi Vincent,
Thank a lot for advice.
The binary contain terminal '\0' , strcat/strcpy just copy partial of data.
Regards
Alvin