Data Transformation Engine Functions and Expressions Reference Guide

Chapter 3 - Function Reference DBQUERY
Functions and Expressions Reference Guide
92
! The order of the keywords is not important.
All database-specific parameters are optional.
Returns
This function returns a single-text-item.
If your SQL statement is a SELECT statement, this function returns the results
of the query in the same format as a query specified as a map input card,
including row delimiters and terminators, and so on.
If your SQL statement is anything other than a SELECT statement, this function
returns NONE.
Example
Assume that you have a table named PARTS that contains the following data:
Also assume that this database has been defined using the Database Interface
Designer in a file named mytest.mdq and that the name of the database, as
specified in the .mdq file, is PartsDB.
The
DBQUERY function …
DBQUERY ( "SELECT * from PARTS" ,
"mytest.mdq" ,
"PartsDB" )
… returns 1|¼" x 3" Bolt<cr><lf>2|¼" x 4" Bolt<cr><lf> where <cr><lf>
is a carriage return followed by a line feed.
Using Meaning 2, you can also specify the
DBQUERY this way:
DBQUERY ( "SELECT * from PARTS" ,
"-MDQ mytest.mdq -DBNAME PartsDB" )
where both the .mdq file name and database name are specified.
Or, specify it this way, using Meaning 2 by specifying the database type and
the appropriate database-specific parameters:
DBQUERY ( "SELECT * from PARTS" ,
"-DBTYPE ORACLE -CONNECT MyDB -USER janes" )