cswebdev
asked on
Fox query result to variable
in MS sql we can store a query result to a variable like :
declare @dt as datetime
select top 1 @dt = age from table
how can i do similar thing in Fox Pro Query. I am using Visual Fox Pro 9
declare @dt as datetime
select top 1 @dt = age from table
how can i do similar thing in Fox Pro Query. I am using Visual Fox Pro 9
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And don't forget to close the cursor :-)
You can write it as a function.
You send a table name and a field name.
You can get the value and return it to a calling procedure like this:
RETURN EVALUATE(FIELD(1))
Moreover, FoxPro has better ways for getting that:
CALCULATE MAX(field), MIN(field) FOR condition TO nVariableMax, nVariableMin
You send a table name and a field name.
You can get the value and return it to a calling procedure like this:
RETURN EVALUATE(FIELD(1))
Moreover, FoxPro has better ways for getting that:
CALCULATE MAX(field), MIN(field) FOR condition TO nVariableMax, nVariableMin
SELECT TOP 1 Something ;
FROM MyTable ;
WHERE <some criteria>
ORDER BY <some field sequence>
INTO CURSOR Results
* --- Select Resultant Cursor, Then put first record into Variable ---
SELECT Results
Variable = Results.Something && Where 'Something' represents a field such as Age
Good Luck