[Oledb-dev] Query parameters?

Marko Bozikovic bozho at kset.org
Tue Oct 17 14:49:35 UTC 2006


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
ICQ: 5990814

I'm not under the alkafluence of inkahol
that some thinkle peep I am.
It's just the drunker I sit here the longer I get.


More information about the Oledb-devel mailing list