General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
I don't know if this is related, Albert, but here it is for what it's worth...
...I've had trouble when I've included references to array elements in the FOR clause of a DELETE... command. The error was something like 'expression evaluator failed'. I got around the error by putting the array element contents into memvars first and using the memvars in the FOR clause.
good luck
>Hi Y'all,
>
>I have a view that is used for deleting printouts (records) by our users. It is a parameterized view that joins a parent record with multiple child records. Users can pick from a list of printouts and either delete one of the printouts or use a checkbox in a grid to delete a bunch of them at once. This view never seems to fail on a single record but sometimes fails if the users want to delete over 8 or 10 records in one fell swoop. I have a feeling it might be failing in how I work with the view. I "reuse" the view after each deletion to then go on to a new record. Here is the code:
>
>* init var before view opens first time or user is prompted
>STORE 0 TO lnPrintOut_ID
>USE v_DeleteOnePrintout
>
>* this view join results in multiple rows so set buffering to table
>CURSORSETPROP("Buffering",5)
>
>* an array exists that holds the id's of the printouts to be deleted; loop
>* through it requerying the view for each printout parent record
>
>FOR lnAtRow = 1 TO ALEN(laPrintOutsList)
>
> * load the Printout_Id into the var needed by the view
> STORE laPrintoutsList[lnAtRow] TO lnPrintout_ID
>
> * requery to fill the view with records
> REQUERY()
>
> * nuke all the records
> DELETE ALL
>
> * post the view: post all rows and force the update
> STORE TABLEUPDATE(.T.,.T.) TO llPostedOkay
>
> * (code here to handle if not posted okay)
>
> * was having trouble here with errors firing occasionally saying that
> * the view had uncommitted changes (when requeried the next printout) so
> * added a TABLEREVERT() below and this seemed to stop that message
>
> TABLEREVERT(.T.)
>
>ENDFOR
>
>*** End of code sample ***
>
>Question: is it "better" to close the view altogether between deletes (ie. with a simple USE); I did not go this route with the above figuring it would
>be faster to keep the view open and just requery it between printouts? But maybe this is problematic somehow
>
>Thanks,
>Albert
Previous
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