Library code snippets
Data-shaped SQL clauses
Since it's introduction in ADO 2.0, data shaping has remained largely
on the fringes of Visual Basic arcanum. Relegated to the back pages of
musty manuals, you may have overlooked this useful aspect of ADO. If
you're not familiar with data-shaping, in essence, it lets you create
recordsets within recordsets--or parent/child relationships--all with a
single ADO object. This means no messy joins, no complicated filtering,
and no need for spaghetti-code in presentation logic. Data shaping
reduces the amount of traffic crossing a network, provides more
flexibility when using aggregate functions, and reduces overhead when
interfacing with leading-edge tools like XML.
To create a shaped recordset, you use a standard SQL statement, along
with three major keywords: SHAPE, APPEND, and RELATE, like so
SHAPE {SELECT EmployeeID,FirstName, LastName
FROM Employees}
APPEND ({SELECT OrderID, shipname, EmployeeID
FROM orders} AS SomeAlias
RELATE EmployeeID TO EmployeeID);
The SHAPE keyword specifies and defines the parent recordset. Once you
create a parent object, you next APPEND the child recordset. This
clause uses a similar syntax as SHAPE and contains the necessary SQL
statement to create the child recordset within the parent. In addition
to the child recordset's SQL statement, you must also indicate how you
want the two recordsets to RELATE.
Related articles
Related discussion
-
dtPicker date format query
by konikula (1 replies)
-
MS Access in 3 different language
by buvanasubi (1 replies)
-
copying access DB to SQL DB
by Lufuno (0 replies)
-
How to receive data in web server sending from GPRS modem
by ashok.infotech (0 replies)
-
Run-time error '91'
by crazyidane (0 replies)
Related podcasts
-
Stack Overflow: Podcast #28
This is the twenty-eighth episode of the StackOverflow podcast, where Joel and Jeff discuss Windows Azure, SQL Server 2008 full text search, Bayesian filtering, porn detection, and project management — among other things. Jeff met the inestimable Joey DeVilla aka Accordion Guy...
Events coming up
-
Jun
16
Code Generation 2009
Cambridge, United Kingdom
A developer event with a practical focus on helping people get to grips with code generation tools and technologies.
This thread is for discussions of Data-shaped SQL clauses.