tsanchez
27th December 2001, 12:21
Hello there. Is there someway I can avoid the interruption of
a session due to fatal errors in commit transaction ? I guess
I could use the db._____ set of instructions but I don't know
which ones or how. Could you please gimme a clue ?
Thanks in advance.
Tomas Sanchez Tejero
tsanchez@consultant.com
Youp2001
11th January 2002, 14:34
It depends on the kind of fatal error you get and on the Baan version you're using. Please give some more details.
tsanchez
12th January 2002, 18:08
What about a 606 fatal error ? I think that's the code which
means there has been a refential integrity error. Anyhow,
which errors can be controlled and how ? You've all my
attention.
Thanks in advance.
Tomas Sanchez Tejero
tsanchez@consultant.com
lbencic
14th January 2002, 19:11
You can capture some errors with the db.update, but it is better to not program the common errors in to begin with. Before inserting, check for duplicates. Before inserting or updating, check all the references on the table. This is the common method. Baan coding does not normally check for errors after the action, they try and be sure no errors will occur before inserting/updating.
~Vamsi
14th January 2002, 21:36
error.bypass = true
your select statements here
db.update/insert here
if e then
on case e
case EREFNOTEXISTS:
do what you want to do here
break
write code for other error conditions
break
default:
endcase
endif
error.bypass = false
With error.bypass set to true you will have to manage all the error handling yourself. So set it to false at the first available opportunity.
tsanchez
15th January 2002, 22:33
Thanks both for your help. Specially you Vamsi for those
revealing lines of source code. But I' ve still one doubt.
If I recall correctly I could add an eflag as a parameter
beside the usual db.retry. How it's supposed to match
this in our puzzle ? Could it be used somehow for
controlling our reference error too ?
Thanks for all.
Tomas Sanchez Tejero
tsanchez@consultant.com
lbencic
15th January 2002, 22:56
Yes - when updating you can use the following syntax:
db.retry.point()
select tablename .*
from tablename for update
where conditions
selectdo
....
db.update(ttablename, db.retry, db.return.ref.not.exists)
selecteos
commit.transaction
endselect
This is from the standard Baan help on error handling. The db.return.ref.not.exists will hold the error code to that if a reference error occurs. This captures the errors and does NOT result in a retry. Some more options:
db.return.error - this returns any error, not just reference.
db.skip.dupl - skips theupdate if duplicates occur..program continues
db.exit.on.dupl - stops the session if duplicates occur
db.skip.rowchanged - skip action if record has been changed after delayed lock
Full listing in Baan help available online.
~Vamsi
15th January 2002, 23:17
Tomas,
Go with Lisa's solution. That is more suited for your current needs. The code I posted gives an insight into the possibilities :). One of my colleagues used that code to check for "enotable" error.
tsanchez
17th January 2002, 00:16
Thanks for all the great advices. Then, I guess I could check
which value took the "e" variable after Lisa's endselect just
as Vamsi did in his code snippet, although error.bypass was
not used. Am I right ?
Tomas Sanchez Tejero
tsanchez@consultant.com