Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Usability of date syntax in SQL
Message
De
10/04/2003 08:22:45
 
 
À
10/04/2003 04:02:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00775883
Message ID:
00775958
Vues:
11
>Have you tried
>
>
>ldDate = DATE()
>lcSQL = "SELECT Numero FROM News WHERE StartDate=CTOD( '" + DTOC( ldDate) + "')"
>
>
>Its clunky though - with the CTOD in the expression that will get evaluated.
>
>We use Private variables to pass variables in our SQL expressions - something you probably don't want to do but...
>
>eg.
>
>PRIVATE pdDate
>pdDate = DATE()
>lcSQL = "SELECT Numero FROM News WHERE StartDate = ?pdDate"
>...pass SQL expression
>RELEASE pdDate
>
>
>and then have code to evaluate the variables prefixed with the question mark.
>
>again, it has its downsides with the variable being available in other methods and PRGs, but the lifetime of the variable is usually quite short - and if you have a standard naming convention for the Private vars then they shouldn't really clash with others.

Yes, as I mentioned, the goal is to have a static SQL and not dynamic. So, I need to make that SQL syntax to be available in other methods without having to create object properties or to pass method parameters.

Using a SQL where the WHERE clause would use CTOD() is not as optimizable as:
SELECT Numero FROM News WHERE StartDate={^2003/04/10}
which I updated after I created this thread. So, this is better than to have to CTOD() for every record it has to go through.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform