Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DLL Declaration
Message
From
14/02/2008 10:22:15
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
DLL Declaration
Miscellaneous
Thread ID:
01292575
Message ID:
01292575
Views:
50
I have a stored procedure in my database that return a GUID. This stored procedure is called from the Default value of the primary key of each table. It work fine, but it need the declaration of 2 DLL functions to work (CoCreateGuid and StringFromGUID2) and the declaration is a bottleneck in a batch process. Each DECLARE statement take in average 0.02s to execute, so it add up quickly in an insert batch process.

The DECLARE could be moved in the application instead of inside the stored procedure, but it will mean that I wouldn't be able to insert new records in a browse window.

Is there a way to execute these DECLARE only once and that it could work in both environement? (in the application and in a browse window) Or do you have a quicker alternative function that return a GUID?

Here's the stored procedure:
PROCEDURE GetGUID
        *-- These DECLARE statement take in average 0.02s each to execute
	DECLARE INTEGER CoCreateGuid IN Ole32.dll STRING @lcGUIDStruc
	DECLARE INTEGER StringFromGUID2 IN Ole32.dll STRING cGUIDStruc, STRING @cGUID, LONG nSize

	LOCAL lcGUID AS String, lcStrucGUID AS String, lnSize AS Integer
	lcStrucGUID = SPACE (16)
	lcGUID      = SPACE (80)
	lnSize      = 40
	
	IF CoCreateGuid (@lcStrucGUID) <> 0
	   RETURN ""
	ENDIF

	IF StringFromGUID2 (lcStrucGUID, @lcGuid, lnSize) = 0
	  RETURN ""
	ENDIF

	RETURN CHRTRAN (STRCONV (LEFT (m.lcGUID, 76), 6), "{}", "")
ENDPROC
TIA
Next
Reply
Map
View

Click here to load this message in the networking platform