Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query Challenge 7: string of child fields in each parent
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00208157
Message ID:
00208207
Vues:
31
I forget how to fix the length of the field in the query (exact syntax or something). If you can refresh my memory, I'll try it right now. Meanwhile, my SQL looks like SELECT keyfield, field2, ChildList(keyfield), orderfield FROM things INTO CURSOR mycursor ORDER BY orderfield. ChildList(keyfield) does a SELECT parentkey, dockey FROM thingdocs WHERE parentkey = keyfield INTO ARRAY aMyarray and then builds a string of fields from DOCS whose dockeys are in that array.

Mr. Bob Archer, I'm not using this thing for a report. I need it for a West Wind demo program which I will use to convince my bosses to buy WWWC. The wwShowCursor class expects a single selected cursor as input. I could probably cobble something with code but I always prefer a SQL solution.

>Brett,
>
>Can you post the original SELECT that you tried... you say that the UDF is trying to return the correct string but that it doesn't show up.
>
>Possibly your problem is the *length* of the field that you output which is associated with *that* UDF (eg ... MyUDF() AS WhatIWant...). The VFP SQL will use the length of the first value encountered to set the length for every other occurrence!
>
>Jim N
>
>>I have a query that reads values from one table and also is supposed to use a UDF to assemble a string of values from a related table. If I JOIN the other table in the query (using a common table, because the two tables are related many-many) I get only the first value in the string. If I leave that other table out of the join, the query gets nothing from the UDF, even though the UDF is trying to return the correct string (verified with a WAIT WINDOW). The goal is to format data from two tables in a particular way for a web program (from West Wind) that expects a single cursor. The original Fox report ran directly off the table and called the UDF in a report object. I have:
>>
>>THINGS
>>thingnum  description
>>1         something
>>2         something else
>>3         yet another thing
>>DOCS
>>docnum    docdescript
>>1         "important doc"
>>2         "more important"
>>3         "whatever"
>>THINGDOCS
>>thingkey  dockey
>>1         1
>>1         2
>>2         3
>>3         2
>>3         3
>>
>>I want a query THINGSWITHDOCS that would look like:
>>
>>thingnum  docstring
>>1         "important doc/more important"
>>2         "whatever"
>>3         "more important/whatever"
>>
>>
>>The Help says that you cannot assume anything about work areas and aliases when you use a UDF in a query and I'm sure that it is part of my problem. So, my attempts to do SELECT thingnum, getdocs(thingnum) FROM things are not working, because getdocs wants to open another work area. When I join docs and thingdocs to things with various JOIN, LEFT JOIN, or FULL JOIN, I get duplicates or blank doc strings or only the first item in the docstring.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform