API methods on binary link

Olivier vidal_olivier at yahoo.fr
Sun Jan 23 07:57:27 CST 2005


Ruslan,

for the moment, The simplest API equivalent of the following SQL query  
is it ? :

SELECT zip, city, street FROM ZipCityTb, StreetTb WHERE left (zip, 2) =  
'75' ORDER by zip, city, street

( The problem is that I do not manage to cast results Set in Arrayset.  
I do not thus have to use " findStartWith ")

   dim setStreetOneCity, setAll,setZipArray, set2  As varraySet
   dim a,b,i,j,k,m,n As integer

   setAll=new varraySet(50)

   setZipArray=  
base.zipCity.stringField("zipcode").findAsArraySet("75000")
   setzipArray=base.zipCity.sort(setzipArray,new  
vsortItem(base.zipCity.zipCode), new vsortItem(base.zipCity.CityName))
   k=setZipArray.count
   for i=1 to k
     a=setZipArray.ItemAt(i)
      
setstreetOneCity=base.linkCityStreet.findLinked(a,base.zipCity,base.stre 
et)
     m=setstreetOneCity.count
     for j=1 to m
       setAll.append setStreetOneCity.itemAt(j)
     next j
   next i

   setAll=base.street.sort(setall,base.street.namestreet)

   k=setall.count
   for i=1 to k
     listBox1.AddRow ""
     a=setAll.ItemAt(i)
     base.street.recID=a
      
listBox1.cell(i-1,2)=base.street.varcharField("namestreet").getstring
     set2=base.linkCityStreet.findLinked(a,base.street,base.zipCity)
     a=set2.itemAt(1)
     base.zipCity.recID=a
     listbox1.cell(i-1,0)=base.zipCity.stringField("zipcode").getstring
     listbox1.cell(i-1,1)=base.zipCity.varCharField("cityname").getstring
   next i

it's works well.

If the user now wants to sort out all the list only by street (and not  
by city), it is necessary to begin again all the operation. right ?

Two questions Ruslan:

- What are exactly the advantages of the binary links on objectPtr?

- The API asks for much more code. Is the result really faster? Only on  
of very big dbs?

thank you very much Ruslan

olivier


Le 22 janv. 05, à 19:37, Olivier a écrit :

> Hi Ruslan and list,
>
> I have the impression that it is not easy to use the API when we want  
> to obtain sorts of temporary tables (consisted of fields of several  
> linked tables).
> It is maybe because I still thinks in term of SQL.
>
> For example, always with my tables of zip / city and streets.
>
> I have a datagrid which has to display in the opening of the window a  
> list with three columns.
> First column: zip (table ZipCity)
> The second column: city (table ZipCity)
> The third column: street (table Streets)
>
> It has to display all the streets with the zip beginning with 75.
> The list must be sorted out by zip, city, street.
>
> Ex:
> 75001 	 PARIS 	 street of Kiev
> 75001 	 PARIS 	 street Clemenceau
> 75001 	 PARIS 	 place Vendôme
> 75002 	 PARIS 	 impasse of Bordeaux
>
> The first one and the second column are thus two fields of the table  
> "zip/city"
> The third column is a field of the table "streets".
>
> In SQL:
>
> SELECT zip, city, street FROM ZipCityTb, StreetTb WHERE left (zip, 2)  
> = '75' ORDER by zip, city, street
>
> We obtain then a cursor with which I can easily fill my datagrid.
> Especially, the cursor keeps a number for all the line " zip, city,  
> street ", even if originally they are two different tables.
> It is very practical to modify couples " zipCity-Streets " for  
> example, because the couple is kept in 1 line of the cursor.
>
> But with the sets it is less evident because 1 set is attached to 1  
> single table.
>
> The sets are perfected to work on a table but on any?
> In my example, I do not manage to obtain a practical code.
>
> please, How would you make to make an equivalent of this SQL query?
>
> thank you very much
>
> olivier
>
>
>
> Le 22 janv. 05, à 14:13, Ruslan Zasukhin a écrit :
>
>> On 1/22/05 2:03 PM, "Olivier" <vidal_olivier at yahoo.fr> wrote:
>>
>>> Hi Ruslan and list,
>>>
>>>> I have a table of ZIP-Citys :
>>>>
>>>>   zip=new vstring("zip",5,EVflag.fIndexed)
>>>>   city=new vvarChar("city",100,EVflag.fIndexed+EVflag.findexByWords)
>>>>   CityIdx=new vvarChar("cityIdx",100,EVflag.fIndexed,"city")
>>>>
>>>> and a table of streets :
>>>>
>>>>   street=new
>>>> vvarChar("street",100,EVflag.fIndexed+EVflag.fIndexByWords)
>>>>   streetIdx=new vvarChar("streetIdx",25,EVflag.findexed,"street")
>>>>
>>>> Every street belongs to a couple zip / city :
>>>>
>>>> link_Street_ZipCity=new vbinaryLink("link_Street_ZipCity",  
>>>> ZipCityTb,
>>>> StreetTb, EVlinkType.kOne, EVlinkType.kMany)
>>>>
>>>>
>>>
>>> If I want to see all the streets the zip of which begins with '33',  
>>> in
>>> SQL I makes:
>>>
>>> SELECT * FROM ZIPCity, Streets WHERE left(zip,2)='33'
>>
>> You make at first search in table ZIP
>>
>>     set1 = fldZip.Find( 33 )
>>
>> Now you can iterate set and use
>>
>>     Link.FindLinked(
>>         inRecID as Integer, inTableA as VTable, inTableB as VTable
>>
>>
>> Hmm, we need enable into V4RB one more function that do
>>
>>     set = Link.FindLinked( inSet, TA, TB )
>>
>> We have such func in kernel.
>>
>>
>> -- 
>> Best regards,
>> Ruslan Zasukhin      [ I feel the need...the need for speed ]
>> -------------------------------------------------------------
>> e-mail: ruslan at paradigmasoft.com
>> web: http://www.paradigmasoft.com
>>
>> To subscribe to the Valentina mail list go to:
>> http://lists.macserve.net/mailman/listinfo/valentina
>> -------------------------------------------------------------
>>
>>
>> _______________________________________________
>> Valentina-beta mailing list
>> Valentina-beta at lists.macserve.net
>> http://lists.macserve.net/mailman/listinfo/valentina-beta
>>
>
> _______________________________________________
> Valentina-beta mailing list
> Valentina-beta at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina-beta
>



More information about the Valentina-beta mailing list