From: Paul D B on
Stephen Quinn wrote:
> Paul
>
>> You'll need to have a descending or custom index to achieve that.
> I should qualify that by adding 'as long as your using a relation'
>
> If you don't use a relationship and set the index scope
> programmatically, you could use the Seek() method on DBServer.
>
> CYA
> Steve

Hi Steve,

I don't think I can do this with an descending index.

Say the master file are the Customers.
The relation with the detail file is on the field #CustNr.
The detail file are the invoices per customer. Each invoice record has a
date field.
I've got an index order on this detail file with key
Str(InvCustNr,6)+DTos(Invdate). The order is Descending so the most recent
invoice shows first.

So far so good but I wouldn't know how to set a relation that works. AFAIK
in a relation you can only specify a field, not an expression.

--
Paul


From: Jean-Pierre Maertens on
from the helpfile :

<cbRelationBlock> The relation code block for the server.

imo you can specify an expression like :

self:odbCustomers:setrelation(self:odbInvoices,{||str(_field->custnr,6)},"str(_field->custnr,6)")


>
> Hi Steve,
>
> I don't think I can do this with an descending index.
>
> Say the master file are the Customers.
> The relation with the detail file is on the field #CustNr.
> The detail file are the invoices per customer. Each invoice record has a date
> field.
> I've got an index order on this detail file with key
> Str(InvCustNr,6)+DTos(Invdate). The order is Descending so the most recent
> invoice shows first.
>
> So far so good but I wouldn't know how to set a relation that works. AFAIK in
> a relation you can only specify a field, not an expression.

--
Jean-Pierre Maertens


From: Paul D B on
Jean-Pierre Maertens wrote:
> from the helpfile :
>
> <cbRelationBlock> The relation code block for the server.
>
> imo you can specify an expression like :
>
> self:odbCustomers:setrelation(self:odbInvoices,{||str(_field->custnr,6)},"str(_field->custnr,6)")
>
>
>>
>> Hi Steve,
>>
>> I don't think I can do this with an descending index.
>>
>> Say the master file are the Customers.
>> The relation with the detail file is on the field #CustNr.
>> The detail file are the invoices per customer. Each invoice record
>> has a date field.
>> I've got an index order on this detail file with key
>> Str(InvCustNr,6)+DTos(Invdate). The order is Descending so the most
>> recent invoice shows first.
>>
>> So far so good but I wouldn't know how to set a relation that works.
>> AFAIK in a relation you can only specify a field, not an expression.

Hi JP, long time no hear!

Well that works! But I tried something similar earlier but then I only
passed in the codeblock.
self:odbCustomers:setrelation(self:odbInvoices,{||str(_field->custnr,6)})
and then it does NOT work.

I thought the codeblock was enough and that the string parameter was
optional.
The Help says: cRelationBlock> When the relation is specified as a code
block, a string version of the code block *can* be provided as well; it is
returned by the Relation() method.


Apparantly is is not optional but obligatory.

Anyway, many thanks again

--
Paul


From: Stephen Quinn on
Paul

A relation is set on a common field in both DBFs
The field doesn't have to be in the index expression (of the chld)
The child HAS to have an index - in your situ a descending index.


> Apparantly is is not optional but obligatory.
Providing the string version (as well as/ or instead of the cb only) is
always 'safer/better' I've found (VO2.5)

CYA
Steve


From: Paul D B on
Stephen Quinn wrote:
> Paul
>
> A relation is set on a common field in both DBFs
> The field doesn't have to be in the index expression (of the chld)

of the master, you mean... ?


--
Paul


First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4
Prev: Help with C# Source
Next: VO2Ado Parameterized Query