Prodataset : Fill() Method using Index.

Posted by Admin on 29-May-2009 00:49

Hi All,

   I am using dynamic prodataset in client/server architecture.

    I just want to know :-

* Fill Method generally fill records In Ascending order, If I want fill records in descending order. How can we do that ? 

* Does Fill method use index to fill the records in temp-table , if yes how can we know that which index is being used ?

* Does use-index works for fill method ?

Thanks

Vishwdeep

All Replies

Posted by mary on 01-Jun-2009 11:03

A dataset's queries can be controlled by using your own query, or by using data-source-handle:FILL-WHERE-STRING. Here is a small example that does both, for the sports db.

def temp-table ttcust field cust-num as int field name as char.
def temp-table ttord  field cust-num as int field order-num as int.
def dataset ds for ttcust,ttord
  data-relation r1 for ttcust,ttord relation-fields(cust-num,cust-num).

def query qcust for customer.

query qcust:query-prepare("for each customer by cust-num desc").

def data-source dcust for query qcust.
def data-source dord for order.
buffer ttcust:attach-data-source(data-source dcust:handle).
buffer ttord:attach-data-source(data-source dord:handle).

data-source dord:fill-where-string = "where order.cust-num = ttcust.cust-num by
order-num desc".


dataset ds:fill.

for each ttcust:
   disp ttcust.cust-num.
   for each ttord where ttord.cust-num = ttcust.cust-num.
      disp ttord.cust-num  ttord.order-num.
   end.
end.

Posted by Admin on 02-Jun-2009 01:21

Thanks Mary,

    I got the records in descending order.

   But Still I am confuse about use of index in Fill method of Dataset.

Regards

Vishwdeep

Posted by kevin_saunders on 02-Jun-2009 03:25

The FILL method will use the same Index Selection rules that the rest of the ABL uses. If you specify a query for the FILL then the compiler will determine which index to use based on the WHERE in your query. If there is no query, then the compiler will pick an index (most likely the primary index).

There is a KB article that explains the index selection rules that the ABL uses - P7066 explains some of the criteria behind selection and the 'OpenEdge Data Management: Database Design : Progress 4GL Index Usage' document explains how indexes are selected.

Posted by Admin on 02-Jun-2009 04:15

Thanks  Kevin.

Posted by mary on 02-Jun-2009 08:36

In addition, I would think that how the records in the database data-source are accessed would be irrelevant.  What you care about is how the records in the dataset temp-tables are accessed.   In the example I gave, the dataset temp-tables had no index, so they were "roughly" in the order they were created.  If you want to see them in some particular order, it would be far better to put an index on the temp-tables (e.g. cust-num descending).   You cannot depend on the order used in the FILL, and sorting in reverse order during the FILL is probably a waste of time.

Posted by Tim Kuehn on 02-Jun-2009 09:02

"Deleted" because Mary'd already answered the question.

This thread is closed