Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BUG TYPE('blobfield') AND VARTYPE(blobfield)
Message
From
20/10/2005 18:32:12
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01060805
Message ID:
01060921
Views:
12
>Why TYPE() and VARTYPE() returns different results for field type BLOB
>
>
CLEAR
>CREATE TABLE Test (bugfield W)
>INSERT INTO Test VALUES (FILETOSTR(HOME()+'beautify.app'))
>? TYPE('bugfield')   &&& return W
>? VARTYPE(bugfield)  &&& return Q
because bugfield in VARTYPE(bugfield) it is considered
like a memory expression;
on VFP a binary memory variable have "Q" as datatype.
TYPE('bugfield') it distinguishes the fields instead
CREATE cursor Test (bugfield W)
APPEND BLANK
clear
? TYPE('bugfield'),TYPE('bugfield+0h')
? VARTYPE(bugfield),VARTYPE(bugfield+0h)
This is not a bug.

A bad design there is because if a variable
it contains a varbinary "Q" of length 10000,
this cannot be inserted in
a field Q, but it must be inserts
in a field W (blob);
certainly this is not the ugliest thing of VFP.

The same is true for a field Memo.

Another point is this:
with a large value, TYPE() can to be faster:
clear
CREATE cursor Test (bugfield W)
APPEND BLANK
test(1,1000000)
test(1000000,5000)

PROCEDURE test(n,k)
	replace bugfield WITH REPLICATE('a',m.n)
	t1=SECONDS()
	FOR k=1 TO m.k-1
		=TYPE('bugfield+""')  
	NEXT
	t0=SECONDS()-t1
	t1=SECONDS()
	FOR k=1 TO m.k-1
		=VARTYPE(bugfield+"") 
	NEXT
	t01= SECONDS()-t1
	? "lenght =",n at 10
        ?? "type =" at 25,m.t0 ;
        ?? "vartype =" at 50,m.t01
        ?? "ratio = ",TRANSFORM(ROUND(m.t0/m.t01*100,3)),'%'
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform