Postgres OLE DB provider - query parameters

From: Marko Bozikovic <marko(dot)bozikovic(at)tellus(dot)hr>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Postgres OLE DB provider - query parameters
Date: 2006-10-18 07:06:32
Message-ID: 4535D278.5030009@tellus.hr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hi all,

I'm new to PostgreSQL OLE DB (and PostgreSQL in general :) and I have a
problem with using OLE DB in my C++ code...

I'm porting some code from MS SQL to PostgreSQL... Here's an example of MS SQL
query class (insert_department procedure has two parameters: input string name
and output int4 id):

[
db_command(L"EXECUTE insert_department ?, ? OUTPUT")
]
class QInsertDepartment
{
public:
[ db_param(1, DBPARAMIO_INPUT) ] CComBSTR m_strName;
[ db_param(2, DBPARAMIO_OUTPUT, status=m_dwIDStatus) ] LONG m_lID;

DBSTATUS m_dwIDStatus;
};

I know how to execute a PostgreSQL stored procedure, so I had to change the
class for PostgreSQL a bit:

[
db_command(L"SELECT insert_department(?)")
]
class QInsertDepartment
{
public:
[ db_param(1, DBPARAMIO_INPUT) ] CComBSTR m_strName;
[ db_column(1, status=m_dwIDStatus) ] LONG m_lID;

DBSTATUS m_dwIDStatus;
};

Calling code looks something like this:

QInsertDepartment insertDepartment;

m_session.StartTransaction();

insertDepartment.m_strName = strName.c_str();

HRESULT hr = insertDepartment.Open(m_session);
if (FAILED(hr))
{
...
}
...

insertDepartment.Open() returns DB_E_PARAMNOTOPTIONAL. Here's the relevant
part of the log file (execution of Open):

IDBCreateCommandImpl::CreateCommand
IObjectWithSiteImpl::SetSite
CPgCommand::SetCommandText "SELECT insert_department(?)"
ICommandTextImpl::SetCommandText
CPgCommand::SetParameterInfo
CErrorLookupService::ClearErrorIAccessorImpl::CreateAccessor
CPgCommand::Execute
CErrorLookupService::ClearErrorCPgCommand::FillParams
CErrorLookupService::ClearErrorICommandTextImpl::GetCommandText
IObjectWithSiteImpl::GetSite
IAccessorImpl::GetBindingsCPgCommand::Execute error: FillinValues failed
CErrorLookupService::ReportCustomError HRES 80040e10:
FillinValues failed

My guess is that there is a problem with parsing input parameter(s), since
executing procedures without IN parmeters (just OUT) works ok.

Can anyone help me?

Thank you,
--
Marko Božiković
Tellus d.o.o.
Tel. +385 1 3691 975
Fax +385 1 3691 976
E-Mail: marko(dot)bozikovic(at)tellus(dot)hr
Ogrizovićeva 40a
10000 Zagreb
Hrvatska

Browse pgsql-interfaces by date

  From Date Subject
Next Message Stephen Byers 2006-10-19 03:38:19 binary copy timestamps with libpq
Previous Message Sandeep Khandelwal 2006-10-18 05:23:01 Bulk Load and Extract from PostgreSQL