Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use ? in variables for UPDATE/INSERT statements?
Message
 
À
26/06/2007 15:47:35
Raza Malik
Universal Accounting Software
Edgewater, New Jersey, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7
Divers
Thread ID:
01235643
Message ID:
01235844
Vues:
31
This message has been marked as the solution to the initial question of the thread.
>Hi Cetin...
>
>In the previous example, the ? was a type which I forgot to add. Let me give you
>another example listed below:
>
>*--
>lnUnt_ship = 10
>lcOrd_numb = '1234'
>lcItem_numb = 'TEST"
>lcItm_desc = "Brackets [1/2)"
>
>lcSQL = "UPDATE cOrders SET " + ;
> "unt_ship = unt_ship + " + TRANSFORM(lnUnt_ship) + ", " +;
> "WHERE ord_numb = [" + lcOrd_numb + "] AND itm_numb = [" + lcItm_numb + "] "
>=SQLEXEC(gnC, lcSQL)
>*--
>
>In the example above, the brackets in the lcItm_desc breakes the statement and causes a syntax error. How can I avoid this...
>
>Thank you again
>Raz

SQL Server recognize only apostrophes as string unless SET QUOTED_IDENTIFIER is OFF. Then it will accept double quotes as delimiter. You must change your string to:
TEXT TO lcSQL NOSHOW TEXTMERGE
     UPDATE cOrders SET unt_ship = unt_ship + <<lnUnt_ship>>
	    WHERE ord_numb = '<<lcOrd_numb>>' AND itm_numb = '<<lcItm_numb>>'
ENDTEXT
or:
lcSQL = "UPDATE cOrders SET unt_ship = unt_ship + " + TRANSFORM(lnUnt_ship) +; && No comma at the end
 	" WHERE ord_numb = '" + lcOrd_numb + "' AND itm_numb = '" + lcItm_numb + "'"
or:
lcSQL = "UPDATE cOrders SET unt_ship = unt_ship + ?lnUnt_ship"+; && No comma at the end
 	" WHERE ord_numb = ?lcOrd_numb AND itm_numb = ?lcItm_numb"
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform