4D v16Executing an SQL SELECT request |
||
|
4D v16
Executing an SQL SELECT request
Executing an SQL SELECT request
The method in the example below executes an SQL SELECT request to retrieve values from columns in the Oracle "emp" table, which is a table of employees. This method starts by allocating a handle for the SQL request (request handle). This type of allocation is typical for methods that work with SQL requests (INSERT, UPDATE, DELETE). The method selects all the employees but only certain columns (fields). Here we select the employee number (empno), their name (ename), job title (job) and hire date (hiredate). For each column implicated in the SQL request, we associate an array in 4D to retrieve the values. To link the 4D array with the targeted Oracle column, we use the OCIDefineByPos command, which expects the number of the column mentioned in the SQL request. Since Oracle's Date type is particular in that it consists of both a date and a time part, we have used the same command here as well (OCIDefineByPos command). We did this because the time component is of no interest to us here; otherwise we would have needed to use the OCIDefineDateByPos command. Source code of the OCI_SELECT project method: C_TEXT($sql_request) //label of SQL request
|
PROPERTIES
Product: 4D
HISTORY
ARTICLE USAGE
4D for OCI ( 4D v16) |