The method in the example below executes an SQL UPDATE request to update records that were added previously to the Oracle "emp" table. In this method, we update 3 records that were added by the INSERT request. We are only modifying the names (ename column).
Note that here we have done a bind (association of a 4D variable with an Oracle column) by name. In the previous INSERT request, we did the bind by position.
Source code for OCI_UPDATE project method:
C_TEXT($sql_request)
C_LONGINT($status)
C_LONGINT($errhp)
C_LONGINT($stmthp)
C_LONGINT($bind)
C_POINTER(pnull_ind1;pnull_ind2;pnull_ind3)
C_LONGINT($nb_emp)
ARRAY LONGINT(tlu_empno;3)
ARRAY TEXT(tau_ename;3)
tlu_empno{1}:=1111
tlu_empno{2}:=2222
tlu_empno{3}:=3333
tau_ename{1}:="JJ"
tau_ename{2}:="CC"
tau_ename{3}:="MM"
$sql_request:="UPDATE emp SET ename=:the_names WHERE empno=:the_numbers"
$status:=OCIHandleAlloc(envhp;$stmthp;OCI_HTYPE_STMT)
$status:=OCIHandleAlloc(envhp;$errhp;OCI_HTYPE_ERROR)
$status:=OCIStmtPrepare($stmthp;$errhp;$sql_request;OCI_DEFAULT)
$status:=OCIBindByName($stmthp;$bind;$errhp;":the_names";->
tau_ename;SQLT_STR;pnull_ind1;pnull_ind2;pnull_ind3;OCI_DEFAULT;BIND_IN)
$status:=OCIBindByName($stmthp;$bind;$errhp;":the_numbers";->
tlu_empno;SQLT_INT;pnull_ind1;pnull_ind2;pnull_ind3;OCI_DEFAULT;BIND_IN)
$nb_emp:=3
$status:=OCIStmtExecute(svchp;$stmthp;$errhp;$nb_emp;0;0;0;OCI_DEFAULT)
status:=OCITransCommit(svchp;$errhp;0)
$status:=OCIHandleFree($stmthp)
$status:=OCIHandleFree($errhp)