Example 2 - using DBQUERY to obtain multiple columns or rows
Assume that you have a table named PARTS that consists of the following data:
PART_NUMBER | PART_NAME |
---|---|
1 | 1/4" x 3" Bolt |
2 | 1/4" x 4" Bolt |
Also assume that this database has been defined in a file named mytest.mdq using the Database Interface Designer. The name of the database, as specified in the MDQ file, is PartsDB .
Using the Syntax1 format, the following DBQUERY function:
DBQUERY ("SELECT * from PARTS", "mytest.mdq", "PartsDB")
returns:
1|1/4" x 3" Bolt<cr/lf>2|1/4" x 4" Bolt<cr/lf>
where <cr/lf> is a carriage return followed by a line feed.
Notice that if the same function was executed using DBLOOKUP, the results would be:
1|1/4" x 3" Bolt<cr/lf>2|1/4" x 4" Bolt
The difference between the two results is that the final carriage return/line feed is stripped off the end of the results of the DBLOOKUP function.
Using Syntax2, you can obtain the same results as in the previous DBQUERY function as shown in the following examples:
DBQUERY ("SELECT * from PARTS where PART_NUMBER =1",
"-MDQ mytest.mdq -DBNAME PartsDB")
or:
DBQUERY ("SELECT * from PARTS where PART_NUMBER =1",
"-DBTYPE ORACLE -CONNECT MyDatabase -USER janes
-PASSWORD secretpw")