Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Updating SQL Server table
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01655887
Message ID:
01655894
Vues:
44
>>Hi,
>>
>>I am calling SQL Update command from VFP application. Since I don't know if the matching record is found in the SQL Server, I want to have the results; so that I can count how many record were updated. I thought I can add the name of a cursor and "capture" this. But it does not seem to work. Here is what I am doing:
>>
>>
>>cSqlUpdate = "update mytable set field1 = '1233' where id_field = 'ABC'"
>>nResult = SQLEXEC(hCon, cSqlUpdate, "cur_result")
>>
>>
>>I thought that the cursor "cur_result" would be created on successful update. But Select ("cur_result") is 0 after an update that I see worked. What am I missing?
>>
>>TIA
>>
>
>If you need to know how many rows were updated, you can do
>
>cSQLCommand = "update ...;
>
>select @@RowCOUNT as RowsUpdated;"
>
>Then your cursor will have a single row with the number of rows updated.

Do you mean to add the "@@RowCOUNT as RowsUpdated;" to my SQL update?

That is, would my SQL update command look like this:
cSqlUpdate = "update mytable set field1 = '1233' where id_field = 'ABC';select @@RowCOUNT as RowsUpdated"
I used a semi-colon to separate two statement. Is this correct?

UPDATE. I checked and it works. Thank you!
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform