NO : Postgresql re-establishing connection

David McKeone david at artsman.com
Sun Dec 5 13:13:46 EST 2010


Hi Andy,

The short answer is that it's in $sqlstate of the statement ref, but just so it's clear here is a bit of a summary.

------------------------------------------
$sendSQLDirect
------------------------------------------

Calculate iStatementRef as iSessionObj.$newstatementref('MyStatement')  ;; There is more code to this for testing the validity of the current session, but I summarized it so you can see the important statement part.

Do iStatementRef.$prepare(pStatement) Returns sqlOK
If not(sqlOK)
  Calculate FailedToPrepare as kTrue
Else
  Do iStatementRef.$execute() Returns sqlOK
End If
If not(sqlOK)
  Calculate StateError as $cinst.$getSqlStateDescription(iStatementRef,TryAgain) ;; This is the method that checks the errors listed below
End If

------------------------------------------
$getSqlStateDescription
------------------------------------------

If isclear(pStatementRef)
  Calculate pTryAgain as kTrue
  Quit method ''
End If

If isclear(pStatementRef.$sqlstate)
  Calculate pTryAgain as kTrue
  Quit method ''
End If

Do method defineErrorList ;; Build list of errors and description (if it isn't already)

;; Search the list for the current $sqlstate error code
Do tStringFields.$binarysearch(nam(cSqlStateErrorList),nam(cErrorCode),pStatementRef.$sqlstate,5,kTrue)  ;; Our (very fast) custom binary search -- it's in the TMObjs object we give to everyone at Euromnis
If cSqlStateErrorList.$line>0
  Calculate pTryAgain as cSqlStateErrorList.cTryAgain
  Quit method con('SQL State: ',pStatementRef.$sqlstate,' ',cSqlStateErrorList.cErrorDescription)
Else
  Calculate pTryAgain as kTrue
  Quit method con('SQL State: ',pStatementRef.$sqlstate,' error message is undefined in PGSQL data access method')
End If

__________________________________
David McKeone
Arts Management Systems Ltd.
mailto:david at artsman.com
http://www.artsman.com
Phone: (403) 536-1203 Fax: (403) 536-1210

On 2010-12-04, at 9:11 PM, Andy Hilton wrote:

> David
> 
> looks like a treasure trove - just one question - how are you getting the error code here / where are you testing/finding it ?
> 
> Good advice on the transaction rollback part......
> 
> Andy




More information about the omnisdev-en mailing list