Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQuery
Message
 
 
To
07/05/2008 09:03:21
General information
Forum:
Visual FoxPro
Category:
Stonefield
Title:
Re: SQuery
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01308261
Message ID:
01315766
Views:
19
>>I have another question. I have a Phones table where type identifies the kind of the Phone. Suppose, I'd like to combine two Phones in one field (separated with Chr(13), so it would become Memo field). Is there a way to do so with Stonefield Configuration Utility?
>
>As Frank suggested, I'd created a calculated field. I'd do it in the parent table rather than the Phones table. If you do it in the Phones table, because there could be multiple records for each parent record, you'd end up with multiple instances of the same combined phones.
>
>For example, suppose Phones is a child of Customers, so there are possibly multiple Phones records for each Customer. Also suppose there's a CustomerID field in Phones that's the foreign key to Customers, which has ID as its primary key. In this case, create a calculated field in Customers called Phones and have the output expression of that field call a script and pass it the ID for the Customer record; for example, GetPhones(Customer.ID). Thee code for GetPhones would be similar to the following:
lparameters tiCustomerID
>local lnSelect, lcSelect, lcPhones
>lnSelect = select()
>lcSelect = 'select PhoneNumber, PhoneType from Phones ' + ;
>  'where CustomerID=' + transform(tiCustomerID)
>loDatabase = SQApplication.Databases.GetMainDatabase()
>loDatabase.ExecuteSQLStatement(lcSelect, , 'TempCursor')
>lcPhones = ''
>scan
>  lcPhones = lcPhones + iif(empty(lcPhones), '', chr(13)) + ;
>    trim(PhoneNumber) + ' (' + trim(PhoneType) + ')'
>endscan
>select (lnSelect)
>return lcPhones
This would display something like this in a report:
Customer A  111-111-1111 (Home)
>            222-222-2222 (Work)
>Customer B  333-333-3333 (Home)
>            444-444-4444 (Cell)
>Doug

Thanks, I'm trying it now.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform