Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UDFs in SQL SELECT
Message
De
13/03/2012 15:00:30
 
 
À
13/03/2012 13:06:54
Information générale
Forum:
Visual FoxPro
Catégorie:
FoxPro 2.x
Versions des environnements
Visual FoxPro:
FoxPro Windows
OS:
Windows XP SP2
Divers
Thread ID:
01538216
Message ID:
01538232
Vues:
48
>I wrote a small FPW 2.6a prog to pull data from an old app's Transact.DBF. Simplifying things, here's the problem I'm seeing:
>
>SELECT Transact.*, "Constant" AS ExtraCol FROM Transact WHERE ... INTO TABLE Table1
>(pulls 966 records, as I expected)
>
>SELECT Table1.*, IIF(Col1 = Col2, 1, 0) AS SameCnt FROM Table1 INTO Table2
>(pulls 966 records -- all of the Table1 data, plus the SameCnt column, as expected)
>
>SELECT Table1.*, MyUDF(Col1, Col2) AS SameCnt FROM Table1 INTO Table2
>(pulls only 1 record!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!)
>...
>RETURN
>PROCEDURE MyUDF
>PARAMETERS pCol1, pCol2
>RETURN IIF(pCol1=pCol2, 1, 0)
>
>There are no GROUP BYs. I can't figure out why MyUDF is only pulling one record. I've tried hard-wiring the PATH and the DEFAULT,
>setting both just to the folder that FPW is in and put by prog file there. I've tried MyUDF defined as a PROC and as a FUNC in the
>calling program, and as a separate PRG file in the same folder as the rest. Any environmental settings
>or other factors that could cause this behavior?

I don't see a problem, if your Query #2 works, #3 should work too (assuming you're showing us all the relevant clauses). If those aren't the entire queries, I agree with Sergey, maybe you could show us the actual code.

SWAG1: I can't recall if FPW26 supports NOFILTER on a SELECT - SQL, but if it does, you could add that to your first query (that creates Table1).

SWAG2: In case there is some unexpected MyUDF() being executed, try changing its name to something you're positive hasn't been used before e.g. _zzzz().
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform