![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||||
| |||||
|
|
We're converting an Informix application to Postgresql. We relied on the sqlca structure to report the number of rows changed and errors, but the structure seems to be always set to 0. Here's some actual code (Translated literally from the Informix code, no attempt to optimize, so if it looks especially dumb, that's my excuse :-) Am I missing something obvious? |
|
EXEC SQL execute immediate :stmt; /* stmt is an update statement, presumed to be OK since the update actually happens */ if(error = sqlerror()) goto sqlcleanup |
|
EXEC SQL commit; /* this never shows any error */ if(error = sqlerror()) goto sqlcleanup |
|
/* this always shows zero rows */ if(error = sqlnorows()) goto sqlcleanup |
|
/* The error checking and reporting */ int sqlerror() { [...] if(sqlca.sqlcode) { [...] return 1; } return 0; } /* the rows affected counter */ int sqlnorows() { int row_count = sqlca.sqlerrd[2]; if(row_count == 0) { [...] LOGVIDERR(5, "No rows effected."); return 1; } return 0; } |
#3
| |||
| |||
|
|
/* this always shows zero rows */ if(error = sqlnorows()) goto sqlcleanup This is also as expected, as COMMIT affects zero rows. |
#4
| |||
| |||
|
|
That's it! That's the point we were missing. If you ever get near Phoenix, Arizona, USA, I'll buy lunch <g>. |
#5
| |||
| |||
|
|
Al Balmer <albalmer (AT) att (DOT) net> wrote: That's it! That's the point we were missing. If you ever get near Phoenix, Arizona, USA, I'll buy lunch <g>. If the e-mail address is valid, |
|
I'll collect it some day :^) |
|
Yours, Laurenz Albe |
![]() |
| Thread Tools | |
| Display Modes | |
| |