Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A pseudo SEEK() Function to be used with SPT
Message
 
 
À
05/07/2002 08:54:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00675579
Message ID:
00675657
Vues:
10
The fastest way to check if record or records exist in Sql Server is to use EXISTS operator.
SELECT CASE WHEN EXISTS ( 
		SELECT * FROM pubs..authors WHERE au_id = '213-46-8915') THEN 1  
	ELSE 0 END
>Hi,
>
>I'm new to Client-Server programming and sometimes would like to use standard VFP code to perform some simple tasks when using SQL Pass Thru, but unfortunatelly I can't (many folks asked it many times to MS, OTOH many other folks, many other times said it was unnecessary!).
>
>An example: to check if a specific record exists, just that (a parts item in an inventory, a client by its code etc) and based on the result make a decision.
>
>That's very simple when using DBFs (please see "Standard VFP DML Code" below), but when using SPT I must code a SQL Select and all that "surrounding" code (there is a better way?), so I wondered if it would be a good idea to create a general purpose UDF to do that (please see "Code to be Used With SPT" below).
>
>It's just a prototype idea, and I ask you, please, to help me by making your comments, they'll be very appreciated.
>
> Standard VFP DML Code:
> ---------------------
>
> If Seek (eExpression, cTableAlias)
>    ...
> endif
>
> Code to be Used With SPT:
> ------------------------
>
> If SQLSeek (nHandle, "Customer", "CustNo = 77")  &&  SQLSeek example call
>    ...
> endif
>
> Procedure SQLSeek    &&  The pseudo SEEK() Function
>*--------- -------
> LParameters pHandle   , pTable, pWhereCondition
> Local       cSelectStr, bFound
>
> cSelectStr = " Select * From " + pTableName +
>              IIf (! Empty (pWhereCondition), " Where " + pWhereCondition, "")
>
> SqlExec (pHandle, cSelectStr, "CurSQLSeek")
>
> Select CurSQLSeek
>
> bFound = RecCount () > 0
>
> Use In CurSQLSeek
>
> Return bFound
>
> EndProc
>
>
>TIA
>
>Fernando
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform