Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQLEXEC and Shared Connection Problems
Message
From
11/11/2004 16:32:12
 
 
To
11/11/2004 15:40:48
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8
OS:
Windows XP SP1
Database:
MS SQL Server
Miscellaneous
Thread ID:
00960314
Message ID:
00960638
Views:
12
Hi Fabio,

The AllowSimultaneousFetch wasn't specifically designed to support asynchronous execution. It was designed to support simultaneous fetch using two or more SPT connection handles sharing the same ODBC connection, but with synchronous execution. Primarily, with remote views and CursorAdapter objects.

The support for simultaneous fetch depends on the driver's capabilities to perform it. Obviously, ODBC driver for Sql Server is not capable to do this when asynchronous execution is in effect. Normally, it would give you an error as soon as you try to execute something without finishing/canceling the async execution, but when you try to force it with AllowSimultaneousFetch = .T. the driver goes into wait state, I assume it is waiting for the first execution to complete its work.

Thanks,
Aleksey.


>Can you debug this end run it well ( i have a CPU 100% )
>
>CLEAR
>#define _StatementBusy_ "ConnectBusy"
>SQLSETPROP(0,"BatchMode",.T.)
>SQLSETPROP(0,"Asynchronous",.F.)
>s1=SQLCONNECT('temp_mariano',.T.)
>s2=SQLCONNECT(m.s1)
>
>TEXT TO sqlCmd NOSHOW
>	CREATE TABLE #TABLE1 (F1 INT IDENTITY,F2 TEXT)
>	INSERT #TABLE1 (F2) VALUES (REPLICATE('ciao',1000))
>	DECLARE @n INT
>	SELECT  @n=1
>	WHILE @n<8
>	BEGIN
>	  SELECT @n=@n+1
>	  INSERT #TABLE1 (F2) SELECT F2 FROM #TABLE1
>	END
>	SELECT * INTO #TABLE2 FROM #TABLE1
>	SELECT @@ROWCOUNT n
>ENDTEXT
>
>IF SQLEXEC(m.s1,m.sqlCmd,'NUMBER')=1
>	? 'Expected ',NUMBER.n
>	* end build context
>
>	? SQLSETPROP(m.s1,"Asynchronous",.T.);
>	, SQLSETPROP(m.s2,"Asynchronous",.T.)
>
>	=CURSORSETPROP("AllowSimultaneousFetch",.T.,0)
>	=CURSORSETPROP("FetchAsNeeded",.F.,0)
>	=CURSORSETPROP("FetchSize",10,0)
>	waitfree(m.s1)
>	? 'Start 1',SQLEXEC(m.s1,"SELECT * FROM #TABLE1","cursor1")
>	? 'stmt 1 busy :',SQLGETPROP(m.s1,_StatementBusy_)
>	? 'stmt 2 busy :',SQLGETPROP(m.s2,_StatementBusy_)
>	*--------------------------------------------
>	* try to uncomment the next line !
>	* showcursor (m.s1,'cursor1')
>	
>	waitfree(m.s2)
>        * when exect this line , the cpu go to 100%
>	? 'Start 2',SQLEXEC(m.s2,"SELECT * FROM #TABLE2","cursor2"),MESSAGE()
>	*---------------------------------------------
>	? 'stmt 1 busy :',SQLGETPROP(m.s1,_StatementBusy_)
>	? 'stmt 2 busy :',SQLGETPROP(m.s2,_StatementBusy_)
>
>	showcursor (m.s2,'cursor2')
>	
>	*showcursor (m.s1,'cursor1')
>	
>	DO WHILE INKEY(0.1)#6
>		DOEVENTS FORCE
>	ENDDO
>
>ENDIF
>
>? SQLCANCEL(m.s2),SQLCANCEL(m.s1)
>? SQLDISCONNECT(m.s2),SQLDISCONNECT(m.s1)
>
>PROCEDURE showcursor (s,c)
>	tout=DATETIME()+20
>	DO WHILE m.tout>DATETIME() AND !USED(m.c)
>		=SQLEXEC(m.s)
>		DOEVENTS FORCE
>	ENDDO
>	IF USED(m.c)
>		SELECT (m.c)
>		BROWSE NOWAIT
>	ENDIF
>
>PROCEDURE waitfree(s)
>	DO WHILE SQLGETPROP(m.s,_StatementBusy_)
>		DOEVENTS FORCE
>	ENDDO
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform