Using Pointers to Fields, Variables, or Arrays

4D - Documentation   Français   English   German   English   4D for Oracle, Command Theme List   4D for Oracle, Command Alphabetical List   Back   Previous   Next

version 1.5


You can use a pointer instead of including the name of a field, variable, or array in the text of a SQL statement.

To use pointers, you leave the substitution field, variable, or array blank (<<>>) in the OD Set SQL in cursor statement and include a pointer to it in a binding statement. The OD BIND TOWARDS SQL and OD BIND TOWARDS 4D commands accept pointers to simple variables, arrays, and fields.

The following method adds the values in two arrays as two rows on the server. Pointers to the arrays are specified in the OD BIND TOWARDS SQL statements.

   vEmpno:=123
   vEname:="Adams"
   $query:="INSERT INTO emp (empno,ename) VALUES (<<>>,<<>>)"
   $rc:=OD Set SQL in cursor (ID_cursor;$query)
   OD BIND TOWARDS SQL (ID_cursor;1;->vEmpno)
   OD BIND TOWARDS SQL (ID_cursor;2;->vEname)   
   OD EXECUTE CURSOR (ID_cursor)

Advantages of Using Pointers

You do not need to reconstruct SQL statements each time you need to redefine a field, variable, or array. For instance, if you change the name of a field or the name of the table to which the field belongs, you do not need to duplicate the change in all SQL statements that refer to the field because the pointer is still valid.

4D Insider, the 4th Dimension cross-reference generator, recognizes fields, variables, or arrays used in methods only when they are referred to by pointers.


4D - Documentation   Français   English   German   English   4D for Oracle, Command Theme List   4D for Oracle, Command Alphabetical List   Back   Previous   Next