Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to put in a string the result of a sql command
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01460395
Message ID:
01460400
Views:
34
>Are you using VFP or SQL Server? If the later, which version. It is a piece of cake in SQL Server 2005 and up. In VFP you need to use custom function.
>

In other words,
function GetPESCAInfo
lparameter tcPesca
local lcResult
lnSelect = select()
if not used(GUIA)
   use GUIA in 0 shared
endif
select * from GUIA where Pesca = m.tcPesca into cursor curTemp nofilter
scan
   lcResult = m.lcResult + curTemp.SomeField + char(13)
endscan
use in select('curTemp')
select (m.lnSelect)
return m.lcResult

select P.*, GetPescaInfo(P.Pesca)  from Pesca P
>>Hello.
>>
>>I work in a shrimp plant. Each day several trucks bring shrimp to the plant, the document each truck has to declare the amount of shrimp that is carrying si called GUIA. Usually we send a group of 3 to 4 trucks to a supplier, that group is organized with a document called PESCA.
>>
>>The table PESCA has a relation one to many with table GUIA. The output that i'm trying to show in the report is like this:
>>
>>Pesca: 520 (Guias: 4777 4778 4780)
>>
>>I don't know how to put three or four lines of GUIA into one single string.
>>
>>this is part of the sql instruction I'm using
>>
>>SELECT pes.Pesca, gu.Guia, .....
>>FROM lg_PescaC as pes ;
>>LEFT JOIN lg_Guia as gu ON pes.Pesca = gu.Pesca
>>
>>I should replace gu.Guia with a function, but don't know how to write it using only sql.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform