Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding LEFT function to a UDF function within SELECT
Message
 
 
To
08/10/2001 19:43:11
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00565747
Message ID:
00565763
Views:
18
This message has been marked as the solution to the initial question of the thread.
To get the size of all fields in SQL Select foxpro uses the first record in the table even if it would be filtered out by where clause. If the first record doesn't have corresponded records in xSS440 table your function will return empty string. FoxPro'll convert it in one character field because the lenght cannot be less than 1 character. To get correct result pad function return value to the max possible lenght. See correction in the code below in bold.
>I have a UDF called SECTIONS.
>SELECT SECTIONS(st300.uid,'2000','FALL') FROM st300
>gives me blanks, but
>SELECT LEFT(SECTIONS(st300.uid,'2000,'FALL'),32) FROM st300
>gives me the correct result (string).
>Anybody knows why?
>
>Here's the function:
>FUNCTION SECTIONS(pUID,pYear,pSem)
>LOCAL xRet, xTemp, xSS440
>xRet=''
>xSS440=zSS+'SS440'	&&zSS is a global variable for path to SS files.
>
>DO CASE
>	CASE UPPER(pSem)="FALL"
>		xSem='1'
>	CASE UPPER(pSem)="SPRING"
>		xSem='2'
>	CASE UPPER(pSem)="SUMMER"
>		xSem='0'
>ENDCASE
>
>*sts='S' means scheduled.
>*List only scheduled sections.
>SELECT sts,sec FROM &xSS440 ;
>WHERE UID=pUID and sem=xSem and year=pYear and sts='S' ;
>ORDER BY UID,per INTO CURSOR xTemp
>
>GO TOP
>DO WHILE NOT EOF()
>	IF EMPTY(xRet) THEN
>		xRet=str(sec,3)
>	ELSE
>		xRet=xret+','+str(sec,3)
>	ENDIF
>	SKIP
>ENDDO
>
><b>Return PADR(xRet,32)</b>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform