Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
>
>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
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement