1 Replies - 5732 Views - Last Post: 17 October 2007 - 12:41 AM Rate Topic: -----

#1 palle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-October 07

reading a blob

Posted 15 October 2007 - 12:20 AM

Hi,
please tell me if this is not the right forum to ask this type of questions and perhaps
guide me to the right one...

I'm using Visual C++, ODBC


I have binary blob stored as BYTEA in a postgreSQL bata base.
The blob starts as this in hex:

0x49 0x53 0x46 0x50 0x4O 0x53 0x54 0x47 0x49 0x53 0x3F 0x89 0x00 0x00
0x40 0x4e 0x00 0x00 0x00 0x00 0x00 0x00 0x40 0x30 0x00 0x00 0x00 0x00
...
...

The data in the first row is a string and a float:
ISFPOSTGIS1.1
...

I'm trying to read the blob with this C++ member:

SQLCHAR * CODBC_Class::readBlob(SQLINTEGER no)
{
//Declare The Local Memory Variables
//
SQLCHAR *blobData;
blob = new SQLCHAR[no];

//Bind The Columns In The Result Data Set Returned To
//
rc = SQLBindCol(StmtHandle, 1, SQL_C_BINARY, (SQLPOINTER) blobData, no, NULL);
//rc = SQLBindCol(StmtHandle, 1, SQL_C_CHAR, (SQLPOINTER) blobData, no, NULL);

rc = SQLFetch(StmtHandle);

//Return The ODBC API Return Code To The Calling Function
//
if(rc != SQL_NO_DATA)
{
return(blobData);
}
else {
delete blobData;
return NULL;
}
}

if I use this row:
rc = SQLBindCol(StmtHandle, 1, SQL_C_BINARY, (SQLPOINTER) blobData, no, NULL);
then the blobData variable will be filled only to 12:th "character" (the reading stops at the first 0x00)

if I use this row:
rc = SQLBindCol(StmtHandle, 1, SQL_C_CHAR, (SQLPOINTER) blobData, no, NULL);
the whole blob will be read, but it will not be binary data.

I would like to be able to read a float value direct from the blobData for example the version no 1.1.

Is there someone out there who can help me?

Kind regards,
Paul

Is This A Good Question/Topic? 0
  • +

Replies To: reading a blob

#2 jjhaag  Icon User is offline

  • me editor am smartastic
  • member icon

Reputation: 44
  • View blog
  • Posts: 1,789
  • Joined: 18-September 07

Re: reading a blob

Posted 17 October 2007 - 12:41 AM

You may want to try this one again on the database forum if you don't get anything a few more days. Or maybe some nice mod or admin will move it or link it over there.

I'm not really familiar with SQL, so I'm sorry I can't be of more help.

-jjh
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1