Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to identify the result of a select statement by VFP7.0 from SQL

Status
Not open for further replies.

dakotafox

Programmer
Apr 14, 2000
53
US
The following command is used is our application, where v1 is the variable containing the unique id.

cSQL = "SELECT * from tblAMC2_practice WHERE sql_d_pk=&v1"
SQLResult= SQLExec(hdlpline,cSQL)

The value of SQLResult is 1, whether records were found or not. How can I identify whether an insert or a update is needed from the set of records I am sending to the sql server.

Thank you
 
Taken from the MSDN documentation:

SQLEXEC( ) returns the number of result sets if there is more than one. SQLEXEC( ) returns 0 if it is still executing and returns 1 when it has finished executing. SQLEXEC( ) returns –1 if a connection level error occurs.

If you provide a cursor for the result set to be placed, you could count those records:

cSQL = "SELECT * from tblAMC2_practice WHERE sql_d_pk=&v1"
SQLResult= SQLExec(hdlpline, cSQL, 'MyCursor')

?RECCOUNT('MyCursor')

Dave S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top