Subject Re: [IBO] Simple question about "Dataset cannot scroll"
Author Helen Borrie
At 03:01 PM 29/11/2004 +1100, you wrote:

>Hi,
>
>I am getting a "Dataset cannot scroll error".
>
>As I have not found the source of the problem. I have written a very simple
>application, which contains two IB_Grids.(One displays the Master
>information and the other the Detail information)
>
>Thus, each IB_grid has a IB_Qery and IB_DataSource. The Idea is that the
>application user can click on record on the IB_Grid containing the Master
>data, and the IB_Grid on the right will display all details records that
>match the master. This works fine.
>
>However, when I try to edit any detail record, I get the following error:
>
>.... EIB_DatasetError with message "Dataset cannot scroll"
>
>The sql use on the master IB_Query_Master is:
>
> SELECT ACM_DOUBLEKNOCK.DN_ID
> FROM ACM_DOUBLEKNOCK
>
>KeyLinks contains:
>
> ACM_DOUBLEKNOCK.DN_ID
>
>And I have not provided Insert, Update or Delete SQL for master
>IB_Query_Master.
>
>
>
>The sql use on the detail IB_Query_Detail is:
>
> SELECT
> ACM_DOUBLEKNOCKITEMS.DNI_DN_ID,
> ACM_DOUBLEKNOCKITEMS.DNI_AC_ID
> FROM ACM_DOUBLEKNOCKITEMS
> LEFT JOIN ALARMCODES
>ON(ACM_DOUBLEKNOCKITEMS.DNI_AC_ID=ALARMCODES.AC_ID)
> LEFT JOIN ACM_DOUBLEKNOCK
>ON(ACM_DOUBLEKNOCKITEMS.DNI_DN_ID=ACM_DOUBLEKNOCK.DN_ID)
>
>The Insert SQL used on IB_Query_Detail is:
>
> INSERT INTO ACM_DOUBLEKNOCKITEMS(
> DNI_AC_ID, /*PK*/
> DNI_DN_ID) /*PK*/
> VALUES (
> :DNI_AC_ID,
> :DNI_DN_ID)
>
>The Update SQL used on IB_Query_Detail is:
>
> UPDATE ACM_DOUBLEKNOCKITEMS SET
> DNI_AC_ID = :DNI_AC_ID, /*PK*/
> DNI_DN_ID = :DNI_DN_ID /*PK*/
> WHERE
> DNI_AC_ID = :OLD_DNI_AC_ID AND
> DNI_DN_ID = :OLD_DNI_DN_ID
>
>The Delete SQL used on IB_Query_Detail is:
>
> DELETE FROM ACM_DOUBLEKNOCKITEMS
> WHERE
> DNI_AC_ID = :OLD_DNI_AC_ID AND
> DNI_DN_ID = :OLD_DNI_DN_ID
>
>KeyLinks contains:
>
> ACM_DOUBLEKNOCKITEMS.DNI_DN_ID
> ACM_DOUBLEKNOCKITEMS.DNI_AC_ID
>
>MasterLinks contains:
>
> DNI_DN_ID=ACM_DOUBLEKNOCK.DN_ID
>
>The detail IB_Query_Detail DataSource property is set to the master
>IB_Query_Master
>
>Any suggestions are welcome at this stage :-)

OK, the first suggestion is that you use MasterSource to set the
detail-to-master linkage!!! Datasource is used for TIBOQuery because the
TDataset architecture doesn't implement Mastersource for its query
components and descendants.

The second suggestion is that you revisit the query you are using to get
the detail dataset. Using outer joins doesn't gel well with master-detail
linking under any conditions but here you have an outer join that actually
involves the master table -- hence introducing a circular relationship of
some kind.

The third thing is that, once you have sorted out a detail set that can
logically be a detail to that master, make certain that you have all of the
keylinks you need in order for the detail dataset to find the required
record in the sets your xxxxSQL statements refer to. You currently have
potential nulls in the key because of the outer joins and the circular
reference to the master.

The fourth suggestion is that (again, once you have that detail set
properly sorted) you absolutely ensure that you refresh the detail set
immediately after performing any DML, since your EditSQL is breaking the
master-detail relationship.

If I ended up with this kind of pickle in a master-detail structure, I'd be
taking a harsh, critical look at my table structures to work out where I
stuffed up in my data modelling.

Helen