User:KELightsey/sandbox/SQL Command Design Pattern

= SQL Command Design Pattern =

The word command is defined as "to direct with authority; give orders to" and "to have at one's disposal". It implies having both the ability and resources to make something happen.

The software the command design pattern is a behavioral design pattern in which an object is used to represent and encapsulate all the information needed to call a method at a later time. This information includes the method name, the object that owns the method and values for the method parameters.

The following example implements xml objects as commands using the SQL language. These command objects are then passed to an engine for processing.

Note that the resultant design is not intended to model an ideal scenario as design requirements are unique to each application. The design is solely intended to illustrate the use of SQL components as command pattern objects.

= Example =

For the example an engine will be built. XML will be used to build up a typed XML object that contains both the SQL statement and parameters required for sp_executesql. The execution engine well execute the object using the parameters applied, and return the output as part of the object.

object
An xml schema collection is used to type a object as:

engine
The engine for the object. Note that the engine has no knowledge of the actual command being run nor of the output being returned. All details of the command itself including output are encapsulated in the object.

[design_pattern].[get]
Sample method to show use of [design_pattern].[run].

Multiple examples are shown to illustrate the execution engine handling different types of objects.

Example 2
...      -- --