Today's Quiz. How many times is a user function called?
Run the code below. How many times is the function FOO called? Why?
The first SELECT is a single table query. The next is a 2 table self-join with no join condition.
PUBLIC nCount
nCount=0
CREATE CURSOR test (name c(10))
nRecs=5
FOR i = 1 TO nRecs
INSERT INTO test VALUES ("test"+TRANSFORM(i))
ENDFOR
SELECT name,foo(name) AS foo FROM test INTO CURSOR result
?"Count = ",nCount
nCount=0
CLOSE DATABASES all
nCount=0
CREATE CURSOR test (name c(10))
FOR i = 1 TO nRecs
INSERT INTO test VALUES ("test"+TRANSFORM(i))
ENDFOR
SELECT a.name,foo(a.name) AS foo FROM test a, test b INTO CURSOR result
?"Count = ",nCount
PROCEDURE foo(cName)
?PROGRAM(),cName
nCount=nCount+1
RETURN nCount
RETURN