Data Shaping Technology--shape Append command

Source: Internet
Author: User
Tags query require
The Shape APPEND command assigns a child Recordset to the Value property of a Field object in the parent recordset.

Grammar

SHAPE {Parent-command} [[as] parent-alias]

APPEND ({Child-command} [as] Child-alias

RELATE Parent-column to Child-column ...) [[as] chapter-alias] ...

Composition description

The components of this command are:

Parent-command, Child-command one of the following.

Returns the Recordset object in the query command in angle brackets ("{}"). The command is published to the base data provider, and its syntax depends on the provider's requirements. Although ADO does not require the use of any of the specified query languages, it is usually the use of Structured Query Language (SQL). Parentheses ("()") are required keywords that append a subset column to the parent of the Recordset returned by the query command.


The name of the previously formed Recordset.


Another Shape command.


Table keyword, followed by the name of the table.
Parent-column the columns in the Recordset returned by Parent-command.

Child-column the columns in the Recordset returned by Child-command.

... The "Parent-column to Child-column" clause is actually a list and separates each defined relationship with a comma.

Chapter-alias alias, a reference to the column appended to the parent.

Parent-alias alias, a reference to the parent Recordset.

Child-alias alias, reference to the child Recordset.

... The clause after the APPEND keyword is actually a list (each clause is separated by commas), and the definition is appended to another column of the parent.

Operation

Emits Parent-command and returns the parent Recordset. It then emits child-command and returns the child Recordset.

For example, Parent-command can return a company's customer recordset from a Customer table, while Child-command returns all the customer's order recordsets from the order list.

In general, the parent and child Recordset objects must each have a column for associating the parent and child. The column is named in the RELATE clause, Parent-column first, child-column in the post. In their own Recordset, columns can have different names, but they must refer to the same information to specify meaningful relationships. For example, Customers and Orders recordsets can have CustomerID fields at the same time.

The data configuration appends a subset column to the parent Recordset. The values in the Subset column are references to the columns in the child Recordset, which satisfy the RELATE clause. That is, the parent-column in the given parent row has the same value as the child-column in all rows in the child collection.

When you access a reference in a subset column, ADO automatically retrieves the Recordset represented by the reference. Note Although all the child recordsets have been retrieved, the subset (chapter) represents only a subset of the rows.

If the appended column is not Chapter-alias, its name is automatically generated. The column's Field object will be appended to the Fields collection of the Recordset object, and its data type will be adchapter.

For more information about locating a hierarchical Recordset, see Accessing Rows in a hierarchical Recordset.

parameterized commands

If you are working with large child recordsets (especially larger than the parent Recordset) and only need to access a subset of the subsets, it is more efficient to use parameterized commands.

The non-parameterized command (not parameterized commands) retrieves the entire parent and child recordsets, appends the subset column to the parent, and then assigns a reference to each parent row for the related subset.

The parameterized command (parameterized commands) retrieves the entire parent recordset, but only the subset Recordset is retrieved when the subset column is accessed. The difference in this retrieval strategy can be beneficial for performance benefits.

For example, you can specify the following:

"SHAPE {SELECT * from customer}"
APPEND ({SELECT * from orders WHERE cust_id =?}
RELATE cust_id to PARAMETER 0) "
The parent and child tables usually have column name cust_id. Child-command have placeholders (that is, "? "), is referenced by the RELATE clause (that is," ...). PARAMETER 0 "). The relationship is between the dominant identified Customer table Parent-column (i.e., cust_id) and the Orders table Child-column (that is, cust_id) that is implicitly identified, specified by the placeholder and "PARAMETER 0".

Note that the PARAMETER clause belongs only to the Shape command syntax. is not associated with the ADO Parameter property and the Parameters collection.

When the Shape command is executed, the following occurs:

Executes the Parent-command and returns the parent Recordset for the Customer table.


Subset columns are appended to the parent Recordset.


When you access a subset column of a parent row, the value of the CUSTOMER.CUST_ID column replaces the orders.cust_id placeholder and executes the child-command.


All rows of the Orders table (where the value of the orders.cust_id column matches the value of the customer.cust_id column) are retrieved.


A reference to the retrieved Zikong (that is, the chapter of the child Recordset) is placed in a subset column of the current row of the parent Recordset.


Repeat step 3-5 when you access a subset column of another row.
Insert Shape COMPUTE Command

It is now valid to embed parameterized commands of parameterized shape commands into any nested number of shapes COMPUTE commands. For example:

SHAPE {Select au_lname, state from authors} APPEND
((SHAPE
(SHAPE
{SELECT * from authors where State =?} Rs
COMPUTE RS, any (rs.state) state, any (rs.au_lname) au_lname
by au_id) rs2
COMPUTE rs2, any (rs2.state) by au_lname)
RELATE state to PARAMETER 0)

Shape Compute Command


The Shape COMPUTE command generates the parent recordset (which consists of references to the child Recordset), optional columns whose contents are the result of the aggregate function of the child Recordset or previously formed Recordset, and any children listed in the optional BY clause The columns of the Recordset.

Grammar

"SHAPE {Child-command} [as] Child-alias

COMPUTE Child-alias [, Aggregate-command-field-list]

[By Grp-field-list] "

Composition description

This command is composed of:

Child-command is one of the following.

Returns the Recordset object in the query command in angle brackets ("{}"). The command is published to the base data provider, and its syntax depends on the provider's requirements. Although ADO does not require the use of any of the specified query languages, it is usually the use of Structured Query Language (SQL).


The name of the previously formed Recordset.


Another shape command.


Table keyword, followed by the name of the table.
Child-alias alias, used to refer to the Recordset returned by Child-command. A child-alias is required in the list of columns in the COMPUTE clause to define the relationship between the parent and child Recordset objects.

A aggregate-command-field-list list that defines the columns in the generated parent that contain the values produced by the aggregate function of the child Recordset.

Grp-field-list a list of columns in a parent and child Recordset object that specifies how rows in the child are grouped.

For each column in Grp-field-list, there are corresponding columns in the parent and child Recordset objects. For each row of the parent Recordset, the grp-field-list column has a unique value, and the child Recordset referenced by the parent row consists of the Zikong (whose grp-field-list column contains the same value as the parent row).

If the COMPUTE clause contains an aggregate function but does not have a by clause, then only one parent row contains the aggregate value of the entire child Recordset. If you have a by clause, then there are multiple parent rows that contain the aggregate value of the reference and the child Recordset respectively.

Operation

Child-command is published to the provider and returns the child Recordset.

The COMPUTE clause specifies the column of the parent Recordset, which can be a reference to a child Recordset, one or more totals, a calculated expression, or a new column. If you have a by clause, the column that it defines is appended to the parent Recordset at the same time. The BY clause specifies the child



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.