Kbase P123202: Accessing Datasource Query attribute destroys dataset relation
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  05/04/2007 |
|
Status: Unverified
FACT(s) (Environment):
OpenEdge 10.1x
SYMPTOM(s):
Accessing Datasource Query attribute destroys dataset relation
Displaying a datasource QUERY attribute shows all records instead of showing those according to the dataset relation.
ProDataSet relation is broken by accessing the QUERY attribute of a datasource.
For example:
DEFINE DATASET dsOrder FOR dtOrderHeader,dtOrderDetail
DATA-RELATION dtOrderHeader-dtOrderDetail FOR dtOrderHeader , dtOrderDetail
RELATION-FIELDS (Ordernum,Ordernum).
.
.
.
hdataset:FILL().
DO iCnt = 1 TO hDataSet:NUM-BUFFERS:
hDataSet:GET-BUFFER-HANDLE(iCnt):DETACH-DATA-SOURCE().
END.
FOR EACH dtOrderHeader :
DISPLAY dtOrderHeader.
END.
FOR EACH dtOrderDetail :
DISPLAY dtOrderDetail.
END.
.
.
.
DataSrc = SESSION:FIRST-DATA-SOURCE.
DO WHILE VALID-HANDLE(hDataSrc):
/* The following line is the problem */
cDataSource = STRING(hDataSrc:QUERY).
hDataSrc = hDataSrc:NEXT-SIBLING.
END.
CAUSE:
This behavior is expected and the relation is not destroyed. What is happening is that Progress generates an automatic query and fill-where-string when a query is not defined for the data-source. This is done with the function attach-data-source().
When detach-data-source() is called, Progress deletes the automatic query and fill-where-string. If the code then tries to get the QUERY attribute after the datasource has been detached, there is no query so the client tries to generate an automatic query again. However, because the datasource is not attached to a dataset, it generates a query that does a table scan, since it knows nothing about the dataset's relation until it's attached.
Essentially, if you query the datasource's QUERY attribute before it's attached, then Progress will have to generate an automatic query for it.
FIX:
Move the code to get the query before the datasource is detached, or reset the fill-where-query when the datasource is re-attached.