Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select with DateTime and Int
Message
De
14/06/2019 12:42:23
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01669054
Message ID:
01669093
Vues:
46
>
>I use ODBC, not ADO. And I don't use - in this particular case - the parameterized SQL Select. The entire SQL Select expression is passed to a function and the variables are not in scope. And in this case I am not concerned about Injection since user can only select/specify the date. All other parts of the expression are in the VFP code (hard-coded).

Then there is some ODBC driver that you use and supports VFP? Nice. Then:
IF m.plSqlServer
	cLifeExpFilter = " AND (PURCHASED IS NOT NULL AND LIFE_EXP IS NOT NULL AND LIFE_EXP > 0 AND ( " +;
                                " ?m.dPassDate >= DATEADD( year, LIFE_EXP, PURCHASED)) ) "
ELSE
        *-- VFP DB
      cLifeExpFilter = " AND (!EMPTY(PURCHASED) AND LIFE_EXP > 0 AND ?m.dPassDate  >= GOMONTH(PURCHASED,LIFE_EXP*12))"
ENDIF 

* this needs to be in scope where SQLExec is executed only.
* until that SQL is simply a string
dPassDate = date()  && but could be a different date since user can change it from the current date to a future date
SQLExec(m.handle, ...)
"And in this case I am not concerned about Injection since user can only select/specify the date."

Unfortunately many programmers think parameters are only for 'SQL injection Attack'. They are not. They are also to pass the values correctly for the backend (driver knows how to pass a date value for example).
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform