Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL and Functions
Message
From
21/11/1997 19:56:00
 
 
To
21/11/1997 18:25:24
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00061695
Message ID:
00061714
Views:
48
When you call a UDF in a SELECT SQL, VFP evaluates the UDF and dimensions the field with the length of the value returned by the UDF. In your case, probably the result for the first record is 1 char long.

To fix that, return from your function:

RETURN PADR(lcRetValue,lnMaxLength)

Vlad


>I have a strange thing happening and can't find any good documentation on calling UDF's from a SQL statement.
>
>when I execute this SQL (Abridged) the functions are returning the correct string values, yet the cursor shows only the first instance of a letter.
>
>SELECT convertCType(c.cardtypes)AS ctypes, ;
> convertTtype(c.transtype) AS ttypes, ;
> cardtypes,transtype;
> FROM changes AS c
>
>
>FUNC convertTtype(ttype)
>*set step on
>ret = ""
>IF BITAND(1,ttype) # 0
> ret = ret + "S"
>ENDIF
>
>IF BITAND(2,ttype)# 0
> ret = ret + " Cr"
>ENDIF
>RETURN ret
>ENDF
>
>I always get either "S" in the column or if a 2 value it shows blank. I KNOW that the function returns the proper value. Also, how can I make an SQL column more than 6 characters long. It will cut off extra letters if I put for instance "A very large sale" as a return value. It seems that VFP is not as ANSI '92 compatible as MS would lead you to believe.
Previous
Reply
Map
View

Click here to load this message in the networking platform