sc_select(dataset, "SQL Command", "Connection")

This macro executes the SQL commands passed as parameter and access the "dataset" in the command.

Different from sc_lookup macro, this macro doesn't manipulate the dataset (the user is responsible for all the manipulation).

If an error occurs in the sql command execution, the variable attributed to the database returns as "false" and the error message is available in the "dataset_error" variable.

The connection parameter is optional, use only if the command is executed in a data base different from the specified in the application. In this parameter it is not possible to use variables.


Ex. 1:

sc_select(my_data, "select clientId, clientName, limitecred from costumers");
if ({my_data} === false)
{
echo "Access error. Message =". {my_data_erro};
}
else
{
while (!{my_data}->EOF)
{
{clientName} = {my_data}->fields[1];
{my_data}->MoveNext();
}
{my_data}->Close();
}



Ex. 2: The SQL command can passed as application fields (local variables) or of global variables.
sc_select(dataset,"select price order from order where clientId = '{clientId}' and cod_Seller = [var_glo_seller]");

Note: The command must always be finished with semicolon";".