SourceDefaultQuery indexed-reposition
 
Forums / SmartComponent Library - Developer Forum / SourceDefaultQuery indexed-reposition

SourceDefaultQuery indexed-reposition

6 posts, 0 answered
  1. Bert Strobbe
    Bert Strobbe avatar
    19 posts
    Registered:
    25 Oct 2018
    01 Apr 2019
    Link to this post
    We have a question about the use of indexed-reposition in SourceDefault query.
    I'll start off with an error we get and finish with the question.
    Right now, the BED will generate following code (eMEDIUM is the top buffer, eMEDIUM_MLD contains translations and is a child buffer).

       method override public character SourceDefaultQuery (pcTable as character):

            @SourceDefaultQueryCaseBlock.
            case pcTable:
                when "eMEDIUM":u then
                    return "for each MEDIUM indexed-reposition":u.
                when "eMEDIUM_MLD":u then
                    return "for each MEDIUM_MLD indexed-reposition":u.
            end case.

        end method.

    We have a MediumForm with EntityTable eMEDIUM and EntityView eMEDIUM_MLD.
    We also have another form that references eMEDIUM. The reference field had a button that starts the MediumForm and repositions to the currently selected reference.
    We do repositioning with SmartBusinessEntityAdapter:FindRowWhere(cWhere, FindRowWhereModeEnum:FindOnServer).

    Medium is a small table and only contains 7 records. So there won't be enough records to fill a batch.
    FetchDataInternal tries to fill a complete batch in another call. See code following following comment in DataAccess:
            /* Mike Fechner, Consultingwerk Ltd. 19.11.2012
               Bug 2837: Verify that a FindRowWhere on the server does always return
               a full batch of records.  */

    This code will throw an error:
    ** Unable to understand after -- "indexed-reposition". (247)
    PREPARE syntax is: {FOR | PRESELECT} EACH  OF.. WHERE ... etc". (7324)
    Failed to auto-prepare an automatic fill query. (11981)
    FILL of buffer eMEDIUM_MLD with user-supplied query requires that the query be QUERY-PREPARED. (11876)

    FetchDataInternal Consultingwerk.OERA.DataAccess at line 2588  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\OERA\DataAccess.r)
    FetchDataInternal Consultingwerk.OERA.DataAccess at line 2638  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\OERA\DataAccess.r)
    FetchData Consultingwerk.OERA.DataAccess at line 2033  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\OERA\DataAccess.r)
    FetchData Consultingwerk.OERA.BusinessEntity at line 997  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\OERA\BusinessEntity.r)
    FetchData Consultingwerk.OERA.BusinessEntity at line 1071  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\OERA\BusinessEntity.r)
    FetchData Consultingwerk.OERA.ServiceInterface at line 863  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\OERA\ServiceInterface.r)
    OERA/support/proSIretrieve.p at line 1925  (C:\Users\bs\git\smartcomponents_original_full\OERA\support\proSIretrieve.r)
    RetrieveData Consultingwerk.OERA.ServiceAdapter at line 7206  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\OERA\ServiceAdapter.r)
    RetrieveData be.cce.SmartTools.OERA.MonitoringServiceAdapter at line 1604  (C:\Users\bs\git\ccesmarttools\CceSmartTools\src\be\cce\SmartTools\OERA\MonitoringServiceAdapter.r)
    RetrieveData Consultingwerk.SmartComponents.Implementation.SmartBusinessEntityAdapter at line 3355  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\SmartComponents\Implementation\SmartBusinessEntityAdapter.r)
    RetrieveData Consultingwerk.SmartComponents.Implementation.SmartBusinessEntityAdapter at line 3912  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\SmartComponents\Implementation\SmartBusinessEntityAdapter.r)
    FindRowWhere Consultingwerk.SmartComponents.Implementation.SmartBusinessEntityAdapter at line 1929  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\SmartComponents\Implementation\SmartBusinessEntityAdapter.r)
    PositionAdapterToReferenceValue be.cce.SmartTools.SmartComponents.CceBaseForm at line 1296  (C:\Users\bs\git\ccesmarttools\CceSmartTools\src\be\cce\SmartTools\SmartComponents\CceBaseForm.r)
    OnShown be.cce.SmartTools.SmartComponents.CceBaseForm at line 1239  (C:\Users\bs\git\ccesmarttools\CceSmartTools\src\be\cce\SmartTools\SmartComponents\CceBaseForm.r)
    PerformLookup be.cce.SmartTools.SmartComponents.CceBaseForm at line 1357  (C:\Users\bs\git\ccesmarttools\CceSmartTools\src\be\cce\SmartTools\SmartComponents\CceBaseForm.r)
    ...

    The code does work if we remove indexed-reposition from the querystring of eMEDIUM_MLD.
    We feel the framework or even Progress should know when to add indexed-reposition to the querystring and that it shouldn't be included in the DataAccess.
    Do you have any guidelines when to put it there and when not or can we find out when not to put it there?
  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    01 Apr 2019 in reply to Bert Strobbe
    Link to this post
    I doubt that it's the indexed-reposition that's causing the issue. That should be legal in any query string. 

    Can you please provide the relevant client logfile lines when the CustomLogEntryType DataAccess is active with Consultingwerk.OERA.LogFetchDataDetails = TRUE. 

    I'd like to see the source default query, the client query and the resulting prepare string. 

    The layout of your screens should be irrelevant. The same request should return the same result even from the Business Entity Tester or a 3 liner. 

    We feel the framework or even Progress should know when to add indexed-reposition to the querystring and that it shouldn't be included in the DataAccess.


    Based on which rule-set? I don't think that in the framework we can make up for any shortcomings in the query processing capabilities of the ABL.

    The source default query is the database query to which the client filter is added. IMHO this should include indexed-repositiorn 
  3. Bert Strobbe
    Bert Strobbe avatar
    19 posts
    Registered:
    25 Oct 2018
    02 Apr 2019 in reply to Mike Fechner
    Link to this post
     Here are the logfile lines you requested.
    [19/04/02@17:16:38.377+0200] P-011136 T-034268 1 4GL DataAccess Client-Query: FOR EACH eMEDIUM BY eMEDIUM.MED-CODE
    [19/04/02@17:16:38.377+0200] P-011136 T-034268 1 4GL DataAccess Default-Query: for each MEDIUM where MEDIUM.AP-NR = GetApplnr('MEDIUM') indexed-reposition
    [19/04/02@17:16:38.382+0200] P-011136 T-034268 1 4GL DataAccess Prepare-Query: for each MEDIUM where MEDIUM.AP-NR = 101 BY MEDIUM.MED-CODE indexed-reposition
    [19/04/02@17:16:38.382+0200] P-011136 T-034268 1 4GL DataAccess Index Information on Buffer MEDIUM: MEDIUM1
    [19/04/02@17:16:38.407+0200] P-011136 T-034268 1 4GL DataAccess Restart-Rowid for Table eMEDIUM: 0x0000000000000220
    [19/04/02@17:16:38.432+0200] P-011136 T-034268 1 4GL DataAccess Client-Query: FOR EACH eMEDIUM BY eMEDIUM.MED-CODE
    [19/04/02@17:16:38.432+0200] P-011136 T-034268 1 4GL DataAccess Default-Query: for each MEDIUM where MEDIUM.AP-NR = GetApplnr('MEDIUM') indexed-reposition
    [19/04/02@17:16:38.473+0200] P-011136 T-034268 1 4GL DataAccess Prepare-Query: for each MEDIUM where MEDIUM.AP-NR = 101 BY MEDIUM.MED-CODE DESCENDING indexed-reposition
    [19/04/02@17:16:38.473+0200] P-011136 T-034268 1 4GL DataAccess Index Information on Buffer MEDIUM: MEDIUM1
    [19/04/02@17:16:38.477+0200] P-011136 T-034268 1 4GL DataAccess Restart-Rowid for Table eMEDIUM: ?
  4. Bert Strobbe
    Bert Strobbe avatar
    19 posts
    Registered:
    25 Oct 2018
    02 Apr 2019 in reply to Bert Strobbe
    Link to this post
    Maybe related: in the BED tester, with following filter:
    for each eMEDIUM by eMEDIUM.MED-CODE
    we get an error when also select eMEDIUM_MLD:

    QUERY-OPEN for query  requires a previous QUERY-PREPARE. (7312)

    RetrieveData Consultingwerk.SmartComponents.Implementation.SmartBusinessEntityAdapter at line 4098  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\SmartComponents\Implementation\SmartBusinessEntityAdapter.r)
    FetchDataFromBackend Consultingwerk.SmartComponents.Tools.OERABusinessEntityTester.OERABusinessEntityTesterUserControl at line 945  (C:\Users\bs\git\smartcomponents_original_full\Consultingwerk\SmartComponents\Tools\OERABusinessEntityTester\OERABusinessEntityTesterUserControl.r)

    With following log lines:
    [19/04/02@17:32:54.988+0200] P-011136 T-034268 1 4GL DataAccess Client-Query: for each eMEDIUM by eMEDIUM.MED-CODE
    [19/04/02@17:32:54.988+0200] P-011136 T-034268 1 4GL DataAccess Default-Query: for each MEDIUM where MEDIUM.AP-NR = GetApplnr('MEDIUM') indexed-reposition
    [19/04/02@17:32:54.994+0200] P-011136 T-034268 1 4GL DataAccess Prepare-Query: for each MEDIUM where MEDIUM.AP-NR = 101 by MEDIUM.MED-CODE indexed-reposition
    [19/04/02@17:32:54.994+0200] P-011136 T-034268 1 4GL DataAccess Index Information on Buffer MEDIUM: MEDIUM1
    [19/04/02@17:32:54.998+0200] P-011136 T-034268 1 4GL DataAccess Restart-Rowid for Table eMEDIUM: ?
    [19/04/02@17:32:55.021+0200] P-011136 T-034268 1 4GL DataAccess Next-Rowid for Table eMEDIUM: ?
    [19/04/02@17:32:55.021+0200] P-011136 T-034268 1 4GL DataAccess Last-Batch for Table eMEDIUM: yes
    [19/04/02@17:32:55.226+0200] P-011136 T-034268 1 4GL DataAccess Client-Query: for each eMEDIUM by eMEDIUM.MED-CODE
    [19/04/02@17:32:55.226+0200] P-011136 T-034268 1 4GL DataAccess Default-Query: for each MEDIUM where MEDIUM.AP-NR = GetApplnr('MEDIUM') indexed-reposition
    [19/04/02@17:32:55.233+0200] P-011136 T-034268 1 4GL DataAccess Prepare-Query: for each MEDIUM where MEDIUM.AP-NR = 101 by MEDIUM.MED-CODE indexed-reposition
    [19/04/02@17:32:55.233+0200] P-011136 T-034268 1 4GL DataAccess Index Information on Buffer MEDIUM: MEDIUM1
    [19/04/02@17:32:55.237+0200] P-011136 T-034268 1 4GL DataAccess Restart-Rowid for Table eMEDIUM: ?
    [19/04/02@17:32:55.263+0200] P-011136 T-034268 1 4GL DataAccess Next-Rowid for Table eMEDIUM: ?
    [19/04/02@17:32:55.263+0200] P-011136 T-034268 1 4GL DataAccess Last-Batch for Table eMEDIUM: yes
  5. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    02 Apr 2019 in reply to Bert Strobbe
    Link to this post
    Are you sure, it's that query string that's erroring? I have tried

    DEFINE TEMP-TABLE medium 
        FIELD ap-nr AS INTEGER 
        FIELD med-code AS CHARACTER .
                    
    DEFINE QUERY q FOR medium. 

    QUERY q:QUERY-PREPARE ("for each MEDIUM where MEDIUM.AP-NR = 101 by MEDIUM.MED-CODE indexed-reposition") . 

    and this executes with no issue, so the query is syntactically correct. Can you provide us with a reproducible for debugging? 
  6. Bert Strobbe
    Bert Strobbe avatar
    19 posts
    Registered:
    25 Oct 2018
    04 Apr 2019 in reply to Mike Fechner
    Link to this post
    I succeeded in reproducing the issue.
    I made a sample business entity in sports2000 on Employee and Vacation with relation on EmpNum.
    You can find it on https://github.com/bertstrobbe/SmartSports

    In our framework we need the query of the child tables specified in SourceDefaultQuery to be used for the Company filter, so we have ForceApplyQueryOnChildTables set to true in the EmployeeDataAccess class.

    The sample contains a runEmployeeForm program that starts the sample form. Initially the form doesn't retrieve data. There is a toolbar button FindGe11 that will perform a FindRowWhere which causes the error.
6 posts, 0 answered