This function takes a database query, gets rows from an external database table and returns them in a vector of records.
getData(vector, service, query, expr1, ... exprn)
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) |
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.
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”.