Use the relationship between tables to create a query

Source: Internet
Author: User

We often need to useCodeCreate a query. The sysquery class provides the queryfromtablerelation method. Of course, the code of this method is exactly the same as the process of constructing a query based on the relationship between tables, however, it is made into a general method, and you don't need to repeat it every time by calling it directly. In addition, there are several good methods in sysquery. It is worth looking at source.
Public static query queryfromtablerelation (Common _ parenttable, tableid _ relationtableid, Boolean _ update = false, Boolean _ norelationnorecords = true)
Function: Construct a query based on the table relationship.
Parameter description:
_ Parenttable: parent table
_ Relationtableid: child table ID
_ Update: whether to allow query to update database records
_ Norelationnorecords: records are not returned if there is no relationship, which is implemented by the following statement:

If (_ Norelationnorecords && Dictrelation. Lines () =   0 )
{
Query. datasourcetable (_ relationtableid). addrange (fieldnum (common, tableid). Value (queryvalue (0));
}

Call example:Query querysalesparmline (Boolean _ forupdate= False)
{
ReturnSysquery: queryfromtablerelation (This, Tablenum (salesparmline), _ forupdate );
}

The code of this function is pretty. It can be seen as the sample code of the dictionraltaion application.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.