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.

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of Data-shaped SQL clauses.

Leave a comment

Sign in or Join us (it's free).

ElementK Journals
AddThis

Related podcasts

  • Rocky Lhotka on Data Access Mania, LINQ and CSLA.NET

    Scott talks with developer and author Rockford Lhotka about the attack of the DALs (Data Access Layers). How can we put LINQ to SQL, LINQ to Entities and classic multi-tiered design all into a larger context? What's the right strategy for your data access needs? Scott's got questions and Rocky's ...

Events coming up

  • Jul 22

    IT Job Seekers Greater Boston (Java, .NET, SQL, LAMP, etc.) July Meetup

    Boston, United States

    6:00pm to 6:30pm: Refreshments and networking6:30pm to 7:00pm: Individual introductions to the group7:00pm to 7:30pm: Job Hunting Tips- interviewing tips- what is hot, what is not- job hunting resources, places to look7:30 - 8:00pm: More networking!If you are a hiring manager, recruiter, or entrepreneur you are welcome to bring with you handouts about your company and opened positions.

Want to stay in touch with what's going on? Follow us on twitter!