Re: Error messages not always reported through the ODBCdriver -STATEMENT ERROR missing - Mailing list pgsql-odbc

From Hiroshi Inoue
Subject Re: Error messages not always reported through the ODBCdriver -STATEMENT ERROR missing
Date
Msg-id 3B8B0365.26654CBB@tpf.co.jp
Whole thread Raw
In response to Error messages not always reported through the ODBC driver - STATEMENT ERROR missing  (Kristis Makris <kristis.makris@datasoft.com>)
List pgsql-odbc
Kristis Makris wrote:
>
> Hi Hiroshi,
>
> Thanks for looking into this.
>
> > > conn=33461048, query='BEGIN'
> > > conn=33461048, query='SELECT Vendor_Remove(1)'
> > >     [ fetched 1 rows ]
> > > conn=33461048, query='COMMIT'
> > > ERROR from backend during send_query: 'ERROR:  <unnamed> referential
> > > integrity violation - key in vendor still referenced from
> > > vendorforwellagreement'
> > > CONN ERROR: func=SQLTransact, desc='', errnum=110, errmsg='ERROR:
> >
> > The error seems to have occured at SQLTransact().
> > Probbably you should catch the error at CommitTrans() not at
> > ExecuteSQL().
>
> Good observation, that makes perfect sense. I now modified my source so
> that the CommitTrans() is called within the try block. Here's the exact
> source:
>
> ******************************************************************************************
>         try
>         {
>          if (db.CanTransact())
>                  db.BeginTrans();
>
>          strStmt = "SELECT Vendor_Remove(";
>          strStmt += LongToString(lID);
>          strStmt += ")";
>
>          db.ExecuteSQL(strStmt);
>
>          if (db.CanTransact())
>                  db.CommitTrans();
>
>         }
>         catch (CDBException* pEx)
>         {
>          if (db.CanTransact())
>                  db.Rollback();
>
>          pEx->ReportError();
>          pEx->Delete();
>
>         AfxMessageBox(_T("Record (Vendor) Delete Failed!"));
>         return FALSE;
>         }
>
>  return TRUE;
>
> ******************************************************************************************
>
> However, I'm still  unable to capture an exception. Program execution
> goes past the ExecuteSQL(), past the CommitTrans(), and skips over the
> catch block. Isn't that bizzare?

I found that CommitTrans() doesn't throw an exception.
You may have to check the return code of CommitTrans().

Too late detection of an error is another issue.
I'm examining it.

regards,
Hiroshi Inoue

pgsql-odbc by date:

Previous
From: Kristis Makris
Date:
Subject: Re: Error messages not always reported through the ODBCdriver -STATEMENT ERROR missing
Next
From: Gilles DAROLD
Date:
Subject: Problem with libpsqlodbc