type error inserting large obj, Win32 ODBC

From: "Sam O'Connor" <samoc(at)netspace(dot)net(dot)au>
To: "pgsql-interfaces(at)postgreSQL(dot)org" <pgsql-interfaces(at)postgreSQL(dot)org>
Subject: type error inserting large obj, Win32 ODBC
Date: 1999-03-22 04:09:18
Message-ID: 36F5C26E.49702D13@netspace.net.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

I'm having a problem getting large objects to work with the IDS ODBC
driver from MS VC++.
I'm Using the MFC CRecordset class to talk to the ODBC driver.
When I try to add a record with a large object stored in a CLongBinary
I get the message below ( see dbms output). If I dont flag the column as
dirty and not NULL, causing the blob to be ignored, the rest of the row
gets updated properly. When I do flag the blob dirty and not NULL then
the driver returns SQL_NEED_DATA in the MFC code and causes
SendLongBinaryData to be called. This sends all the data through then
just before exiting calls SQLParamData again which fails with the error
message.
Below is the error message, the MS code, my setup info and my code.
If anyone can point out what I am doing wrong I would greatly appreciate
it.
If anyone has a completly different better way to do it that would be
just as good.
Some working example code would be best of all.
(If any extra information would be useful I'd be happy to provide it.)
Thanks
Sam O'Connor

---- dbms output ----

ERROR: parser: attribute 'bitmap' is of type 'lo' but expression is of
type 'int4'
You will need to rewrite or cast the expression (1)

---- MS code that is called just before error ----

// Check for another DATA_AT_EXEC
AFX_ODBC_CALL(::SQLParamData(hstmt, &pv));
if (!Check(nRetCode))
{
TRACE0("Error: failure handling long binary value during
update.\n");
ThrowDBException(nRetCode, hstmt);
}

---- environment ----

PostgreSQL ODBMS 6.4.2

MS VC++6.0 (Using MFC CRecordset class to access ODBC) (Win95)

PostgreSQL ODBC driver from IDS version 6.40.0004 1/8/99
Connection options:
No boxes checked, IF version 6.4
Driver options:
Disable Genetic Optimiser
KSQO
Unknown size: Maximum
Text as LongVarChar
Bool as char
cache size: 100
max VarChar: 254
max LongVarChar: 4094
Sys table prefixes: dd_;

---- database setup ----

create type lo (
internallength=4,
externallength=10,
input=int4in,
output=int4out,
default='',
passedbyvalue
);

create table image (
document_id int2,
document_version int2,
image_name text,
bitmap lo,
primary key (document_id, document_version, image_name)
);

---- calling code ----
m_pSet is an uploadDIBSet* (see source below)

CFile file;
file.Open("c:\\test.dib", CFile::modeRead);

m_pSet->AddNew();
m_pSet->m_document_id = 1;
m_pSet->m_document_version = 2;
m_pSet->m_image_name = "Test image name two";
m_pSet->m_bitmap.m_hData = LoadDIBFile (file,
&(m_pSet->m_bitmap.m_dwDataLength));
m_pSet->SetFieldDirty(&(m_pSet->m_bitmap));
m_pSet->SetFieldNull(&(m_pSet->m_bitmap), FALSE);
m_pSet->Update();

---- uploadDIBSet.h ----

class CUploadDIBSet : public CRecordset
{
public:
CUploadDIBSet(CDatabase* pDatabase = NULL);
DECLARE_DYNAMIC(CUploadDIBSet)

int m_document_id;
int m_document_version;
CString m_image_name;
CLongBinary m_bitmap;
public:
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
};

---- uploadDIBSet.cpp ----

#include "stdafx.h"
#include "uploadDIB.h"
#include "uploadDIBSet.h"

IMPLEMENT_DYNAMIC(CUploadDIBSet, CRecordset)

CUploadDIBSet::CUploadDIBSet(CDatabase* pdb) : CRecordset(pdb) {
m_document_id = 0;
m_document_version = 0;
m_image_name = _T("");
m_nFields = 4;
m_nDefaultType = snapshot;
}

CString CUploadDIBSet::GetDefaultConnect() {
return _T("ODBC;DSN=");
}

--
Sam O'Connor, Melbourne Australia
mail: Sam(at)OConnor(dot)net
web: Sam.OConnor.net
--

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Jason Boxman 1999-03-22 04:21:53 hello!
Previous Message Postgres mailing lists 1999-03-21 19:10:57 Re: [INTERFACES] JDBC Query performance