General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
>
>You can't nest them, but you can issue an ON ERROR * inside your error routine. Yu can then subsequently check to see if the view opened.
>
>BTW, how do oyu use an error routine to open views?
Hi Erik,
Here's a stripped down version of an error handler that opens views automatically. Perhaps I am missing something, but it seems the suggestion you gave *is* a nested error handler. I tried adding a line in the ERR1 program that set a subsequent error handler (ERR2.PRG) in case of an error in ERR1 (like 1709 - Database is in use by someone else), but ERR2 is never called and the default VFP error handler displays the error message.
ON ERROR DO ERR1 WITH ERROR(),SYS(2018)
*ERR1.PRG - Begin
LPARAMETERS fpErrNo,fpErrParm
lcErr=ON('ERROR')
ON ERROR
DO CASE
CASE fpErrNo=13 && Alias is not found
IF INDBC(fpErrParm,'View')
* If the error parameter is a view in the current database
* then presumably a SELECT was issued without having USEd the
* view first. So, here, USE the view and then RETRY the
* SELECT statement that caused the error
USE (fpErrParm) IN 0 NODATA && USE the view
ON ERROR &lcErr && Reset the Error procedure
RETRY && Return to the SELECT that cause the error
ENDIF
OTHERWISE
ENDCASE
* Err1.Prg End
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only