Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can’t use double quotes w/ SQL 7 INSERT
Message
De
15/11/2000 13:03:31
 
 
À
15/11/2000 12:51:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00442210
Message ID:
00442217
Vues:
8
>I have an odd situation to say the least. I am trying to use double quotes to my SQL INSERT but I can’t make it work. Check this code and my question below please:
>
>** read the values in table
>** the NVL funtion is to insert blanks if there is nothing on that field
>lc1= NVL(sid,'') && char
>lc2= NVL(Appstat,'') && char
>
>** INSERT works here:
> l_cSQL = "INSERT INTO ADMStat"
> l_cSQL = l_cSQL + " (sid,trkgrp)"
> l_cSQL = l_cSQL + " VALUES ("
> l_cSQL = l_cSQL + "'" + ALLT(lc1) + "'"
> l_cSQL = l_cSQL + ",'" + ALLT(lc2) + "')"
>lnResult=SQLEXEC(l_nHandle,l_cSQL)
>_CLIPTEXT=l_cSQL
>**in this case, this is the value of clip text= INSERT INTO ADMStat (sid,trkgrp) VALUES ('037643431','')
>
>but if I try to change the from single quotes to double like this it will NOT work:
> l_cSQL = 'INSERT INTO ADMStat'
> l_cSQL = l_cSQL + ' (sid,trkgrp)'
> l_cSQL = l_cSQL + ' VALUES ('
> l_cSQL = l_cSQL + '"' + ALLT(lc1) + '"'
> l_cSQL = l_cSQL + ',"'+ ALLT(lc2) + '")'
> lnResult=SQLEXEC(l_nHandle,l_cSQL)
>
>_CLIPTEXT=l_cSQL
>value of clip text = INSERT INTO ADMStat (sid,trkgrp) VALUES ("037643431","")
>
>This is the odd thing. Like I said, the second one does not work in the program, but if I get both values of the clip text into the SQL Server Query Analyzer and run them, they BOTH run.
>What is wrong?

The default behavior of SQL Server is to use single quotes ONLY for strings.

To use either double or single, inside SQL Server you can SET QUOTED_IDENTIFIER OFF, or in your ODBC connection, you can uncheck Use ANSI Quoted Identifiers (in the 3rd step of configuration process).
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