Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem Raising Error in SQL Server
Message
De
21/01/2004 14:20:37
 
 
À
21/01/2004 14:09:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00869151
Message ID:
00869163
Vues:
29
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform