Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Foxpro SQL vs. SQL Server syntax differences?
Message
De
10/08/2009 14:31:12
 
 
À
02/08/2009 23:17:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Divers
Thread ID:
01415825
Message ID:
01417154
Vues:
76
J'aime (1)
Well, someone on the west-wind.com forums gave this code to help convert Sql statement from VFP to Sql Server format. ( full link here: http://www.west-wind.com/wwThreads/default.asp?Thread=2PP17MHZ0&MsgId=2PR1FFRHX )

I have not tested it, but I am just posting it here in case it helps anyone else:

West-Wind user Jukka Salminen posted this:

I can give an example of one solution. I have added a method (fixsql) to my custom wwBusiness subclass that converts from Fox- to SQL-syntax. The current version looks like this:
LPARAMETERS lcSelect
* _DBPrefix = 'dbo.'
If This.nDatamode = 0
  If Vartype(lcSelect) = 'C'
    lcSelect = Strtran(lcSelect, '_DBPrefix.', "")
    lcSelect = Strtran(lcSelect, CRLF,' ')
    RETURN lcSelect
  Endif
Else
  If Vartype(lcSelect) = 'C'
    lcSelect = Strtran(lcSelect, CRLF,'|')
    lcSelect = Strtran(lcSelect, '_DBPrefix', Server.oConfig.cDatabasePrefix)
    lcSelect = Strtran(lcSelect, '==', "=")
    lcSelect = Strtran(lcSelect, 'SUBSTR(', "SUBSTRING(")
    oRegExp.Pattern="isnull\(([^( ]*)\)"
    lcSelect = oRegExp.Replace(lcSelect, "$1 is null ")
    oRegExp.Pattern="not\s*empty\(([^( ]*)\)"
    lcSelect = oRegExp.Replace(lcSelect, "$1 <> '' ")
    oRegExp.Pattern="iif\(([^,]*),([^,]*),([^\)]*)\)"
    lcSelect = oRegExp.Replace(lcSelect, " case when $1 then $2 else $3 end ")
    lcSelect = Strtran(lcSelect, " currency", " money")
*    oRegExp.Pattern="as\s*currency"
*    lcSelect = oRegExp.Replace(lcSelect, "as money")
    lcSelect = Strtran(lcSelect,'|', CRLF)
  Endif
Endif
RETURN lcSelect
Then I call this method ex. in query() like this:
Lparameters lcSelect, lcCursor, lnResultmode
lcSelect = this.fixsql(lcSelect)
Return DoDefault(lcSelect, lcCursor, lnResultmode)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform