Exceptions and old error handling
jda
jda at his.com
Fri Jan 7 07:42:51 CST 2005
>I open a cursor which contains one field (String).
>This String is modified by RB methods and recorded again in the DB.
>If the update fails (unique field: doubloon), the recording is deleted.
>With the old error handling, it is simple, tests it is made IN the loop.
>With the management of the exceptions, what is the most elegant solution?
>
>
If you are using RB, use a try/catch block. Here's is some pseudocode
for adding a record with a unique integer field:
x = generateAUniqueID
do
try
myCursor.LongField("uniqueID").SetString(str(x))
cursPosition = myCursor.addRecord
success = true //this only occurs if the addRecord was successful
catch theError as VException
if theError.ErrorNumber <> EVError.ConstraintUniqueViolation
then //not a duplicate uniqueID
raise theError
end if
x = generateAUniqueID
end try
loop until success
Jon
More information about the Valentina-beta
mailing list