Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SELECT-SQL, DATE() and DATETIME()
Message
De
30/05/2003 13:29:35
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
SELECT-SQL, DATE() and DATETIME()
Divers
Thread ID:
00794631
Message ID:
00794631
Vues:
38
Hi

Reading the messages of the several forum on VFP, I have inasmuch as the totality of the Select-sql is written using DATE() and DATETIME() directly.

But DATE() to DATETIME() are estimated only once, to the beginning of the query, or for every evaluation made in the query ?

On MSQL, GETDATE() is evaluate only at begin, and is costant within the query.

Example:
SELECT ..GETDATE()... FROM ... GETDATE() ....

is equal to

DECLARE @now DATETIME
SET @now = GETDATE()
SELECT .. @now ... FROM ... @now ....
On VFP, DATE() and DATETIME() is eval for every evaluation in the query.
It slows down the query execution, but can build wrong result.

Example:
CREATE CURSOR pivot (id I AUTOINCR )
FOR i=1 TO 1000000
 APPEND BLANK
NEXT
SELECT id,DATETIME() FROM pivot && WHERE (DATETIME()-DTOT(DATE()))%2=0

is not equal to

m.now = DATETIME()
SELECT id,m.now FROM pivot && WHERE (m.now-DTOT(DATE()))%2=0
I think:

we are fortunate:

- little customers work to midnight;
- a lot often the query comes executed in little second ones.

Comment.

Fabio
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform