Menu

#1 "order by", dbReference<T>.?

closed
nobody
None
5
2003-12-08
2002-04-06
No

Hello.
I have been testing GigaBase (version 2.58) and I like
it. :-)

I am interested in using the "order by" clause with
"sort-parameter" being:
- a structure component accessed by dereferencing a
dbReference<>-type object using the dot notation.

I am also interested in using a "sort-list" made up of
several of the above "sort-parameter(s)".

The following example illustrates this:

// #############################################
// ExampleCode #################################
// ###################################### START
class Contract;

class Detail
{
public:
real4 weight;
dbArray< dbReference<Contract> > contracts;

TYPE_DESCRIPTOR((KEY(weight, INDEXED),
RELATION(contracts, detail)));

// [1]
static dbQueryExpression AscendingWeight(
char_t const* NameOfDetailObject)
{
dbQueryExpression expr;
expr=dbComponent(NameOfDetailObject,_T("weight"));
return expr;
}
}; // class Detail

class Contract
{
public:
dbDateTime delivery;
dbReference<Detail> detail;

TYPE_DESCRIPTOR((KEY(delivery, HASHED|INDEXED),
RELATION(detail, contracts)));

typedef dbCursor<Contract> dbCrsr;
static dbQueryExpression AscendingWeight() // [2]
{
return( Detail::AscendingWeight("detail") );
}
}; // class Contract

REGISTER(Detail);
REGISTER(Contract);

void RunQery()
{
Contract::dbCrsr contracts;
dbQuery q;
q = "order by", Contract::AscendingWeight(); //[3]

if ( contracts.select(q) > 0 )
{
do
{
// ...
}
while ( contracts.next() );
}
}
// ##################################### END
// ExampleCode ##############################
// ##########################################

The above classes (Detail and Contract) are from
testdb.cpp in the GigaBase distribution. These have
been modified as follows:

- class <Detail> contains the static function
dbQueryExpression AscendingWeight(char_t const*);

which returns a <dbQueryExpression> to be used by a
<dbQuery> for sorting of records w.r.t. ascending
<Detail::weight>.

- class Contract contains the <dbCrsr> typedef and
the static function:
dbQueryExpression AscendingWeight() // [2]

which returns a <dbQueryExpression> to be used by a
<dbQuery> for sorting of <Contract>-type records
w.r.t. ascending <Detail::weight>.

The RunQery() function above is an example of what I
am interested in achieving, but the
<contracts.select(q)> statement does not achieve the
required sorting.

I realise that, unlike the example code in the
GigaBase distribution, the
Contract::AscendingWeight()
term in the query
q = "order by", Contract::AscendingWeight(); // [3]

is associated with a dbReference<>-type
(Contract::detail) rather than a simpler (non-
dbReference<>-type) term like <Contract::delivery>.

I have checked the "change-logs" for GigaBase versions
2.59-2.61 and this issue is not addressed.

I have tried some "hacks" but have not been able to
resolve this issue myself (lack of "extensive"
comments/implementation notes).

If it were not a problem, I would be interested in
receiving detailed implementation notes about the
GigaBase code (not mentioned in "GigaBase
implementation issues" section of documentation) to
enhance my understanding of the code.

Any help would be greatly appreciated.

Cheers.

Andre
:-)

Discussion

  • Konstantin Knizhnik

    • status: open --> closed
     
  • Konstantin Knizhnik

    Logged In: YES
    user_id=99547

    It is possible in current version of GigaBASE

     

Log in to post a comment.

Auth0 Logo