getData()

This function takes a database query, gets rows from an external database table and returns them in a vector of records.

Syntax

getData(vector, service, query, expr1, ... exprn) 

Parameters

vector the name of the vector in which to return the selected records
service the name of the service to use to make the database query, a string
query a query for the database, a string
expr additional parameter to pass to the database along with the query, any of the basic datatypes (such as money, integer, string)

Usage

Specify the name of the vector in which to put the records returned by the function as the first argument. The function returns a vector with the name specified, containing the selected records.

Specify the service to use when querying the database as the second argument. The services that can be used to make the database queries are defined in the service.xml file. See the Configuration and Administrators Guide for more information about this file and the services described in it.

Specify the query to make of the database as the third argument. The query can be in any database query language (such as SQL) as long as the appropriate service is defined in the service.xml file. Specify any additional parameters to pass to the database along with the query as subsequent arguments.
Note: The query statement must include placeholders, marked by a "?" character, for any additional parameters being passed.

Example

getData(v, 'MyService', 'SELECT col1, col2 FROM myTable WHERE id= ?', 'myId'); gets records from a table named “myTable” using a service named “MyService”, selects the first two columns of every row where the "id" is equal to the value of "myId" and returns them in a vector named “v”.