It looks correct to me, except that you need a BEGIN..END around the ELSE, since there is more than one line to be executed. (see inline)
Also, you might need to SET NOCOUNT ON at the top of the procedure, so rowcount info isn't returned to the client as the first set of info. (although in VFP this usually isn't a problem).
HTH
>I've put together a screen that updates a MS SQL table using ODBC SPT. The following SQL command returns a value of 1 regardless of whether or not any rows were actually updated:
>
--------------------------------------------
BEGIN TRAN
UPDATE FSFormulaAttrib
SET Attrib_Val = "JWTEST"
WHERE Formula_ID = 316206 AND
Attrib_Code = "JWMATCH"
IF @@ROWCOUNT > 0
COMMIT TRAN
ELSE
BEGIN --<< add
RAISERROR ('No rows were updated',11,1)
ROLLBACK TRAN
END -- << add
-------------------------------------------
>
>There are no rows in the table matching the selection criteria. There is one row where the Formula_ID is equal to 316206 but the value of Attrib_Code is 'C_MATCH'. The transaction should have returned a -1, then I could have
>used AERROR() to trap the error and taken the appropriate action.
>
>What gives? Am I coding the SQL transaction correctly? What are my alternatives? Any help would be greatly appreciated.
>
>Jim White
Insanity: Doing the same thing over and over and expecting different results.