Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SEEK() Equivalent for MSSQL, MySQL, Oracle
Message
De
23/10/2003 07:41:14
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00841003
Message ID:
00841484
Vues:
21
Hi There

>I have designed a routine that successfully upsizes the VFP tables and their indexes to a MySQL equivalent.
>
>The problem that I am having is that I use a lot seeks in my code to retrieve data to the user at VFP's breakneck speed but MySQL and I am assuming that this applies to all database servers that conform to some SQL standard, the indexes are structured as FIELD1,FIELD2,... whereas VFP indexes are expression based.
>
>VB can successfully use SQL server based indexes as its seek is structured accordingly but what could be used as an equivalent for VFP.

The only solution is to use SQL Queries to retrieve "sets" of data that match the specified criterion (or criteria). Back End servers are "set-based" [as opposed to VFP which is "row-based"] and the database engines are designed, and optimized, to handle complex queries.

So if you want to do this:
IF SEEK( [value], [table], [tag] )
  SCAN WHILE [field] = [value]
    ...[actions]...
  ENDSCAN
ENDIF
The nearest equivalent would be to use SQL Pass-Through to retrieve the data like this:
lnOK = SQLEXEC( [handle], "SELECT * FROM [table] WHERE [field] = [value]", "curProcessing" )
IF lnOK > 0
  SCAN
     ...[actions]...
  ENDSCAN
ENDIF
To minimise the impact on your application you could write a UDF (e.g. "myseek") that can accept the same parameters as the native SEEK() and return the same result. Then all you need to do is to find and replace your SEEKs with MYSEEKs so that your code ends up like this:
IF MYSEEK( [value], [table], [tag] )
  SCAN WHILE [field] = [value]
    ...[actions]...
  ENDSCAN
ENDIF
----
Regards
Andy Kramek
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform