Truusvlugindewind
Programmer
I remember finding this in a program (cobol/db2/mainframe):
I get angry seeing such code. In my book it is only valid to test for SQLCODE 0 or 100. The rest al always an error. Treating a DB/2 error code as a valid situation is not done. In my book you should code:
The other programmer argued that my code involves extra database access, so it is less efficient.... Can't argue with that.
Collegues around the world: do I fight windmills or do you agree?
Code:
exec sql
INSERT .....
end-sql
if SQLCODE equal -803 *> duplicate key *<
exec sql
UPDATE ....
end-exec
else
if SQLCODE not equal zero
perform db2-error
end-if
end-if
Code:
exec sql
SELECT COUNT ....
end-exec
if w-count greater than zero
exec sql
UPDATE ...
end-exec
else
exec sql
INSERT ...
end-exec
end-if
if SQLCODE not equal zero
perform DB2-error
end-if
Collegues around the world: do I fight windmills or do you agree?