Well, you are right...I forgot that.
The problem is when executing the queries starting
with the second, no exception are throwed in case of failure.
Let me show you the code. The line marked try
to exec a query that shoud not be accepted by the database.
The query is rejected, of course, but no exception
is catched.
void QSaveProcedura::operator()(argument_type
&T)
{
CString sSQL;
// table proceduri, table
contestatii one - to - many
// save only modified
data:
// procedura:
if(m_pProc->m_nOperationCode
!= OPERATION_NONE)
{
sSQL =
m_pProc->GetSqlQuery();
m_result =
T.exec(sSQL);
if(m_pProc->m_nOperationCode == OPERATION_ADDNEW)
{
// get procedura id:
oid procOid = m_result.inserted_oid();
sSQL.Format(_T("SELECT procedura_id FROM proceduri WHERE
proceduri.oid = %li"), procOid);
m_result = T.exec(sSQL);
m_result[0][0].to(m_pProc->m_lProceduraId);
}
else
if(m_pProc->m_nOperationCode == OPERATION_DELETE)
{
// because referential integrity, all contestatii will be
deleted
// by the db server
return;
}
}
// contestatii:
for (int i = 0; i <
m_pProc->m_array.GetSize(); i ++)
{
if(m_pProc->m_array[i].m_nOperationCode != OPERATION_NONE)
{
if(m_pProc->m_array[i].m_nOperationCode ==
OPERATION_ADDNEW)
m_pProc->m_array[i].m_lProceduraId =
m_pProc->m_lProceduraId;
sSQL =
m_pProc->m_array[i].GetSqlQuery(); // *** invalid query,
null value in foreign key, must throw exception *** //
//
*** db
requirements
*** //
T.exec(sSQL);
}
}
}
----- Original Message -----
From: "Bart Samwel" <[EMAIL PROTECTED]>
To: "Marian Naghen" <[EMAIL PROTECTED]>
Sent: Thursday, June 22, 2006 10:22 AM
Subject: Re: [libpqxx-general] multiple queries in
transactors ?
> > I want to use multiple queries in a transactors - derived class in the
> > following way, and it seems not working as expected:
> >
> > void QSaveMyClass::operator()(argument_type &T)
> > {
> > CString sInsertQuery1, sUpdateQuery1, ...etc
> >
> > T.exec (sInsertQuery1);
> > T.exec(sUpdateQuery1);
> >
> > .... etc.
> > }
> >
> > I use libpqxx version 2.5.5. What is wrong and how can I do that ?
>
> It would be very useful if you would show us the error messages! (Or if
> you don't get error messages but it simply doesn't work, could you
> describe the behaviour?)
>
> Cheers,
> Bart
>
_______________________________________________ Libpqxx-general mailing list Libpqxx-general@gborg.postgresql.org http://gborg.postgresql.org/mailman/listinfo/libpqxx-general