User Guide > Procedures > Packaged Queries
 
Packaged Queries
Packaged queries let you use database-specific queries defined within the TDV system and sent for execution on the targeted data source. Sometimes, you already have a complex query written for a particular database and it might not be feasible to rewrite that query in TDV SQL.
For example, your query might require a database-specific feature not available in TDV or perhaps the query takes advantage of the database-specific feature for performance reasons. In such cases, your database-specific query can be created as a packaged query and subsequently be used in other queries.
Multiple database-specific SQL statements can be executed sequentially by the same packaged query as long as only the last SQL statement returns a single cursor with at least a single column output. See the section on Multiple SQL Execution Statements in a Packaged Query.
Every packaged query is associated with a specific data source.
A packaged query is stored in TDV with the associated data source’s metadata, and it functions like a stored procedure, accepting input parameters and producing rows of data. It must have exactly one output parameter that is a cursor with at least one column.
Because the TDV system cannot automatically determine the required inputs and outputs of a database-specific query, it is necessary for the user to supply this information.
For details on specifying parameters for a packaged query, see Specify Input Parameters for a Packaged Query.
For details on executing a packaged query, see Executing a Procedure or Parameterized Query.
This section includes:
Creating a Packaged Query
Specify Input Parameters for a Packaged Query
Multiple SQL Execution Statements in a Packaged Query
DDL Support in Packaged Queries