Hello,
We are using psqlodbc to update a Postgresql database from embedded sql
for cobol.
We have a strange behaviour : the first time we update, the update is
correct (sqlcode 0). I we try the same update, the system return sqlcode
= 100 and sqlstate = 2000.
postgresql.x86_64 9.2.18-1.el7
postgresql-odbc.x86_64 09.03.0100-2.el7
unixODBC.x86_64 2.3.1-11.el7
under Centos 7.2 64 bits.
Here an example to simulaute an upsert :
exec sql
UPDATE testtable SET
num = :testtable-num
, libelle = :testtable-libelle:testtable-libelle-NULL
WHERE num = :testtable-num;
end-exec
if sqlcode = 100 then
exec sql
INSERT into testtable
(
num
, libelle
)
SELECT
:testtable-num
, :testtable-libelle:testtable-libelle-NULL
WHERE NOT EXISTS (SELECT 1 FROM testtable WHERE num =
:testtable-num);
end-exec
end-if
if sqlcode = 0 then
exec sql commit end-exec
end-if
If I call two times the above code with the same content of
testtable-num and testtable-libelle, the first attempt is successful and
all other attempts, even changing the content of the variables, fails.
It was working good under Centos 5.9 32 bits, and Postgres 9.2.
Any idea why ?
Kind regards,
Alain