Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Beginner in SPT Need HELP
Message
From
15/12/2001 08:22:37
 
 
To
14/12/2001 12:48:28
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00594506
Message ID:
00594789
Views:
22
Hi Patrick

As Larry said, you do need to re-run the SQLEXEC(). As you know, the snag with doing this is that it closes the VFP Cursor and so you have to re-do all your settings. The solution is to run the Query into a temporary cursor, then ZAP the original (which does NOT close it) and append from the temporary cursor.

I use this sort of 'safe select' all the time and the overhead is much less than having to reset all the cursor properties every time you re-query the database.

The following code should give you the idea (I haven't specifically tested this code)

FUNCTION RUNQUERY( tnCon, tcSQL, tcCur )
*** Parameters:
*** tnCon = Connection handle
*** tcSQL = SQL Statement to Execute
*** tcCur = Name of the target cursor

LOCAL lnOK, lcTmpCur, lnSelect
*** If the cursor is already open
IF USED( tcCur )
*** Clear it - whatever happens we want to do this!
ZAP IN ( tcCur )
*** Generate a temporary cursor name
lcTmpCur = SYS(2015)
*** Run the query
lnOK = SQLEXEC( tnCon, tcSQL, lcTmpCur )
IF lnOK > 0 AND USED( lcTmpCur )
*** The target cursor was created, so append from it
lnSelect = SELECT()
SELECT ( tcCur )
APPEND FROM DBF( lcTmpCur )
USE IN ( lcTmpCur )
SELECT ( lnSelect )
ENDIF
ELSE
*** Just select directly into the cursor
lnOK = SQLEXEC( tnCon, tcSQL, tcCur )
ENDIF
RETURN lnOK
----
Regards
Andy Kramek
Previous
Reply
Map
View

Click here to load this message in the networking platform