Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is faster: insert from memvar or insert fields?
Message
 
 
To
25/07/2006 13:13:38
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01139366
Message ID:
01139819
Views:
14
>>We're using GUID for PK, so they had to be calculated on each insert using SP. That's time spent, of course, but there is nothing I can do about it.
>
>To add to what Cetin said. If you have an army of PCs generating their own GUIDs that's got to be better than having 1 database server trying to generate GUIDs for everybody. It's like waiting for the subway versus taking a taxi.

We didn't find a problem with application yet. The users work with the particular account and add one record in a time.

For the long process such as LoadNewTRans I see the benefit of Cetin's idea.

I haven't yet worked it out, was busy with some other stuff.

Here is what we're using (hopefully no copyright is violated). Any ideas of speeding this up?
*==============================================================================
* Procedure:		GUID
* Purpose:			Generates a Universally Unique 16 Character Binary Id
* Author:			F1 Technologies
* Parameters:
* Returns:			lcGuid, the unique id
* Notes:			If the results of this function are stored in a field the
*					field should be a Character Binary field with a size of 16.
* Added:			11/10/99
*==============================================================================
function GUID

local lcGUID, lcString1, lcString2, lcString3, lcString4

lcGUID = UUID()
*--Convert the binaries to hex values
lcString1 = BINTOHEX(substr(m.lcGUID, 1, 4))
lcString2 = BINTOHEX(substr(m.lcGUID, 5, 4))
lcString3 = BINTOHEX(substr(m.lcGUID, 9, 4))
lcString4 = BINTOHEX(substr(m.lcGUID, 13, 4))

lcGUID = m.lcString1 + m.lcString2 + m.lcString3 + m.lcString4

lcGUID = left(m.lcGUID, 8) + ;
	substr(m.lcGUID, 10, 4) + substr(m.lcGUID, 15, 4)

return m.lcGUID

endfunc

*===========================================================================
* End: GUID
*===========================================================================

*==============================================================================
* Procedure:		BINTOHEX
* Purpose:			Converts a binary string to character string of hex.
* Author:			F1 Technologies
* Parameters:		lcBin
* Returns:			The converted character string
*==============================================================================
procedure BINTOHEX

lparameters lcBIN

local lcChars, lnBin, lnDigit

lcChars = ""

for lnDigit = 1 to len(m.lcBIN)
	lnBin = asc(substr(m.lcBIN, m.lnDigit, 1))
	lcChars = m.lcChars + ;
		HEXTOCHAR(int(m.lnBin/16)) + ;
		HEXTOCHAR(mod(m.lnBin,16))
endfor

return m.lcChars

endproc
*===========================================================================
* End: BINTOHEX
*===========================================================================

*==============================================================================
* Procedure:		HEXTOCHAR
* Purpose:			Converts a hex number to a character
* Author:			F1 Technologies
* Parameters:		lnHex, the hex number
* Returns:			lnHex
*==============================================================================
procedure HEXTOCHAR
lparameters tnHex

local lnAsc

do case
case between(m.tnHex,0,9)  && 0-9 maps to numbers where ASC48 = 'O'
	lnAsc = 48 + m.tnHex

case between(m.tnHex,10,15) && 10-15 maps tp letters where ASC65 = "A"
	lnAsc = 65 + m.tnHex - 10

endcase

return (chr(m.lnAsc))

endproc
*===========================================================================
* End: HEXTOCHAR
*===========================================================================
function UUID

local lcUUID

declare integer UuidCreate in rpcrt4.dll string @ UUID

lcUUID = space(16)

* Pass lcGUID to the UUIdCreate function
UuidCreate(@lcUUID)

return m.lcUUID

endfunc
*===========================================================================
* End: UUID
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform