Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select User Defined Fuctions Called Multiple Times
Message
De
09/06/2005 19:07:57
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01021938
Message ID:
01021979
Vues:
20
Yes, it's not a "bug", it's "by design".

The only unfortunate thing is they forgot to mention that design aspect in any of the documentation. Not even mentioned in the half-page highlight about "User-defined functions with SELECT".

>Gary,
>
>It's not a bug as Fabio labels it, like Sergey showed it's required for the SQL engine to determine the column type and size. This behavior is by design.
>
>You can potentially use SQL to get all your other columns and use Xbase commands to fill in the column after the SQL executes with your UDF value.
>
>>I have a sql select statement that calls user defined functions (either a program procedure or DBC stored procedure) and have noticed that the UDF is called multiple times for each record returned.
>>
>>In following simplest case, the select statement (table with one record) should produce nSeed = 10, but the output is 20.
>>
>>
>>CLEAR ALL
>>PUBLIC pnSeed
>>
>>pnSeed = 1
>>
>>SELECT  getnumber() as nSeed FROM appkg!one_record_dummy
>>
>>PROCEDURE getnumber
>>	LOCAL lnRetVal
>>	
>>	lnRetVal = 10 * pnSeed
>>	pnSeed   = pnSeed + 1
>>	
>>	RETURN lnRetVal
>>ENDPROC
>>
>>
>>Does anyone know what's causing this and is there a solution (other than not using UDF's with SQl Select Statements)?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform