In other words, if trying to set a value for the variable created an error (because the variable did not exist) then the exception error trap would catch this and the variable would be created before giving it a value again.
This method was necessary in Sybase 8 as there was no available function to determin if a SQL variable existed or not.
Whilst not ideal, the error trap method should still work. However, in Sybase 10 we have discovered that sometimes this approach does not work effectively and an error is still generated.
Fortunately, Sybase 10 provides for a function that can test for the existence of a SQL variable. The function is called VAREXISTS() and when passed the variable name as a string, the function returns 1 if the variable exists and 0 if it does not.