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")
...
endif
Procedure SQLSeek
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