Script functions reference > Script functions in alphabetical order > O > OdbcGetFirst

OdbcGetFirst
Syntax
OdbcGetFirst(str_dbidentifier, str_sql_statement, var_1[, var_2, var_n]);
str_dbidentifier 
str_sql_statement
var_n
Description
Executes an SQL statement and copies the values from the first row in the result set to the specified script variables. The OdbcGetNext function is then used to retrieve the remaining parts of the result set.
The value of the first data source column of the result set will be copied to the first variable in the list of variables. The second column will be copied to the second variable, and so on.
If the number of variables is less than the number of columns in the result set, the last columns that do not have matching variables will be ignored.
If the number of columns in the result set is less than the number of variables, the last variables that do not have matching columns will be cleared.
If the result set from the SQL statement is empty, all variables will be cleared.
Returns
1
0
-1
Example
$st="SELECT CUSTNAME FROM CUSTOMER WHERE CUSTID="+ $cnr + ";"; 
OdbcGetFirst("my_identifier",$st,$custname);
In this example, the data source, my_identifier contains the CUSTOMER table. The $cnr variable should contain the customer ID, which is the key in the CUSTOMER table.
The SQL statement is constructed using the $cnr variable, and OdbcGetFirst is called to retrieve the first row of the CUSTNAME column from the data source.
OpenText StreamServe 5.6 Updated: 2013-03-01