POSTGRESQL error handling

General discussion forum about all databases other than SqlBase.
vianney
France
Posts: 7
Joined: 22 Feb 2022, 09:36
Location: France

POSTGRESQL error handling

Post by vianney » 22 Feb 2022, 10:02

Hi,
i'm working with pg12 and i would like to find the corresponding error between gupta and odbc on a pg database.
I found the matrix for oracle in the documentation TD Connecting SQLWindows Objects to Databases

Best regards

Vianney

a_sivababu
India
Posts: 505
Joined: 10 Mar 2017, 08:46
Location: Chennai,India

Re: POSTGRESQL error handling

Post by a_sivababu » 22 Feb 2022, 14:05

if you want to really get actual error from PG then you can consider the below function as the mapping one will not provide proper error message for PG.


bOk = SqlGetError( hSql, nError, strErrorString )

Turns off backend error mapping and reports real backend errors.

vianney
France
Posts: 7
Joined: 22 Feb 2022, 09:36
Location: France

Re: POSTGRESQL error handling

Post by vianney » 22 Feb 2022, 18:53

hello thanks for the reply. I'll try it.
Best regards.

vianney
France
Posts: 7
Joined: 22 Feb 2022, 09:36
Location: France

Re: POSTGRESQL error handling

Post by vianney » 23 Feb 2022, 10:24

Hi,
So i tried the solution.
I retrieve the good error messge in the variable strErrorString.
But i don't have the good error number in the variable nError. for example i have 39004.

I'm using ODBC 10 (32bits) /postgresql 12/ team developper 7.4
Could you explain me what i've missed ?
best regards

Vianney

vianney
France
Posts: 7
Joined: 22 Feb 2022, 09:36
Location: France

Re: POSTGRESQL error handling

Post by vianney » 24 Mar 2022, 14:57

Hi

I need to manage a specific behavior for the following PG errors :
- 55P03 lock_not_available
- 23505 unique_violation

But the error I receive from the driver is 39004. So I cannot know the exact reason of the error.

Note, for some errors I receive a specific code:
- Division_by_zero I receive 20028
- String_data_right_Truncation 20024
- Invalid_cursor_name : 20034

Is there a way to handle this?

Any configuration of call that allows to retrieve the original error code?

Thanks.

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 2 guests