SQL_lookup_multi Function
Syntax
DIM result as P = SQL_lookup_multi(C conn, C table, C filter, C fieldlist [, SQL::Arguments Args [, L portableSQL]])
DIM result as P = SQL_lookup_multi(SQL::Connection conn, C table, C filter, C fieldlist [, SQL::Arguments Args [, L portableSQL]])
Arguments
- connSQL::ConnectionCharacter
An open SQL::Connection object, named SQL connection string, or ad-hoc SQL connection string.
Using an open SQL::Connection will improve the performance of the lookup.
- tableCharacter
The name of the SQL table to query.
- filterCharacter
Used to uniquely identify the record to lookup. The filter can use arguments (e.g. city = :what_city and state = :what_state)
- fieldsCharacter
A comma delimited list of fields to return.
- ArgsSQL::Arguments
A SQL::Arguments object that defines the arguments used in the filter. Required if the filter uses SQL arguments.
- portableSQLLogical
Default = .f.. Indicates whether or not the query should be executed using Portable SQL.
Returns
- resultPointer
Returns an Xbasic object with properties for each field returned by the query. If multiple records match the filter, only data from the first record is returned. If no records match, returns an empty object.
If an error occurs (e.g. the specified table doesn't exist), returns an object with the following properties:
- errorTextCharacter
A description of the error that occurred, if any.
- flagErrorLogical
If .t., an error occurred. Check the value of errorText for information about the error.
Description
Does a lookup into a SQL table to retrieve multiple values from a record.
Discussion
Example
dim result as p dim cs as c = "::Name::AADemo-Northwind" result = sql_lookup_multi(cs,"customers","customerid = 'ALFKI'","city,country,contactname") ? result = city = "Berlin" contactname = "Maria Anders" country = "Germany" ' Using Arguments: dim args as SQL::Arguments args.set("what_country","USA") result = sql_lookup_multi(cs,"customers","country = :what_country","city,country,contactname",args) ? result = city = "Eugene" contactname = "Howard Snyder" country = "USA"
If you want to retrieve all records that match the filter, use sql_records_get() or sql_query().
See Also