type error inserting large obj, Win32 ODBC - Mailing list pgsql-interfaces
From | Sam O'Connor |
---|---|
Subject | type error inserting large obj, Win32 ODBC |
Date | |
Msg-id | 36F5C26E.49702D13@netspace.net.au Whole thread Raw |
List | 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@OConnor.net web: Sam.OConnor.net --
pgsql-interfaces by date: