Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BUG: VARCHARMAPPING map to char
Message
 
 
To
09/04/2005 05:14:11
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01002650
Message ID:
01003108
Views:
22
See my comments inline:

>Of course!
>But the issue is: how can you preview
>if VFP can determine that character expression result is of fixed lenght ?
>
>Only after try it you are sure 100%!


I agree that help should cover it in more details but why it's so big issue for you? Use CAST() when in doubt.

>
>Some examples, "extremely intuitive", easy to preview!!

Most of them are, if you think about it
>
>* STRING + BINARY CHANGE THE MAPPING
>SELECT;
>	'A'+0h32		;	&& VARCHAR(2)

*** 'A'+0h32 is varchar expression so result is 
***  VARCHAR(2) regardless of SET VARCHARMAPPING

>
>* FIXED LENGHT ?
>SELECT;
>	STR(4)				;	&& VARCHAR(10)
>,	STR(4,10)			;	&& VARCHAR(10)

*** I think it's a bug that STR() with constant (or default) for it's second parameter 
***  is not considered as returning fixed length

>,	DTOC({})			;	&& VARCHAR(10)
>,	TTOC({/ :})			;	&& VARCHAR(19)

*** They're not fixed lenght because their result depends on some SET command(s)

> FROM BYBYBUG INTO CURSOR RRR
>LIST STRUCTURE
>
>* FUNCTION ON LITERAL PARAMETER CHANGE THE MAPPING ?
>SELECT;
>	SPACE(1)			;	&& CHAR(1)
>,	SPACE(INT(1))		;	&& VARCHAR(1) INT() CHANGE THE MAPPING

*** That something that should be documented but is not. 
*** Looks like expression with call to a function as a function parameter makes result varaible length

>,	CHR(1)				;	&& CHAR(1)
>,	CHR(INT(1))			;	&& CHAR(1)	  INT() DON'T CHANGE THE MAPPING

*** You're kidding, right? CHR() always returns 1 character.

> FROM BYBYBUG INTO CURSOR RRR
>LIST STRUCTURE
>
>* OPERATORS CHANGE THE MAPPING ?
>SELECT;
>	SPACE(10*2)			;	&& CHAR(20)		&& -+*/^ NOT CHANGE THE MAPPING
>,	SPACE(10%1000)		;	&& VARCHAR(10)  && %	     CHANGE THE MAPPING BECAUSE %= FUNCTION MOD()

*** This one is not clear, agree.

> FROM BYBYBUG INTO CURSOR RRR
>LIST STRUCTURE
>
>* EMPTY STRING IS MAPPED TO VARCHAR(1)
>SELECT;
>	SUBSTR('ABC',3,1)	;	&& CHAR(1)
>,	SUBSTR('ABC',4,1)	;	&& VARCHAR(1)

*** You cannot represent empty string in char field

> FROM BYBYBUG INTO CURSOR RRR
>LIST STRUCTURE
>
>* ETC.......
>
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform