Skip site navigation (1) Skip section navigation (2)

Re: Error messages not always reported through the ODBCdriver -STATEMENT ERROR missing

From: Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp>
To: Kristis Makris <kristis(dot)makris(at)datasoft(dot)com>
Cc: pgsql-odbc(at)postgresql(dot)org
Subject: Re: Error messages not always reported through the ODBCdriver -STATEMENT ERROR missing
Date: 2001-08-28 02:35:17
Message-ID: 3B8B0365.26654CBB@tpf.co.jp (view raw or flat)
Thread:
Lists: 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

In response to

Responses

pgsql-odbc by date

Next:From: Gilles DAROLDDate: 2001-08-28 17:07:43
Subject: Problem with libpsqlodbc
Previous:From: Kristis MakrisDate: 2001-08-27 20:20:04
Subject: Re: Error messages not always reported through theODBCdriver -STATEMENT ERROR missing

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group