Results 1 to 5 of 5

Thread: VT requery

  1. #1
    Senior Member
    Join Date
    Oct 2012
    Posts
    234

    Question VT requery

    I use parameterized VTs in my applications with indexes and relations. I would need something similar to VFP's requery() statement that retains the set index and relational relationships. So far, I've tried the .refresh() .cursorrefresh() and .sync() methods of the cursoradapter, but they "throw away" both. What and how should I use?

  2. #2
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,150
    Here is the code I used to requery a section (this is a deployed app). Sorry for the font colors: copied from VSCode:

    Code:
    functionsectionRequery(tcPageSection, tcParameter, tuParamVal, tlShowSection) {    if (typeof tlShowSection === "undefined") {
            tlShowSection = false;
        }
        var loSection = Lianja.get(tcPageSection);
        if (typeof loSection === "undefined") {
            //Lianja.showMessage(tcPageSection);
        }
        if (typeof tuParamVal !== "undefined") {
            loSection.setNamedParameter(tcParameter, tuParamVal);
            loSection.setNamedParameter("defaultnamedparameters", "0");
            loSection.reopenTable();
        }
        if (tlShowSection) {
            gotoPageSection(tcPageSection);
        }
        return loSection;
    };
    gotoPageSection of course is another utility function I wrote.

    Hank

  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,781
    Blog Entries
    18
    VTs work against SQL or stored procedures.

    The SQL optimizer will choose the best index and will perform internal engine join operations that it requires.

    You cannot use old-style VFP functionality such as specifying indexes and relations that you are wanting to do with SQL. You can only do that with NoSQL commands. So if thatís something you require use local stored procedures.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Senior Member
    Join Date
    Oct 2012
    Posts
    234
    my problem is much simpler:
    the relationship "disappears" after refresh (or sync)

    Code:
    close tables
    close databases
    open database southwind
    if empty(tableinfo("vt_order_details"))
    	create virtualtable "vt_order_details" connstr "local" as select * from order_details
    else
    	alter virtualtable "vt_order_details" connstr "local" as select * from order_details
    endif
    use orders in 0 order orderid
    select 0
    use vt_order_details
    set relation to orderid into orders
    ?target(1)
    ?relation(1)
    ca=cursoradapter()
    ?ca.refresh()  	&& or ca.sync()
    ?target(1)
    ?relation(1)

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,781
    Blog Entries
    18
    Hi Sandor,

    I have already explained. You can’t use custom relations or index order like that when using VTs.

    If you requery() the VT you need to set your custom relations again afterwards.
    Last edited by barrymavin; 2022-04-18 at 02:43.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us