icTableName | input | character | Database table name |
icPrepare | input | character | Progress for each statement defining what record(s) must be updated. |
icFieldList | input | character | Comma seperated list of field names to update. If this list is empty, the record(s) to update will be deleted. |
icFieldListDataTypes | input | character | Comma seperated list of data type of each field in icFieldList. data type = c (character) d (decimal) i (integer) l (logical) t (date) |
icAbsolute | input | character | chr(2) seperated list of absolute values to write to the fields of icFieldList. The same value(s) will be written to each record to update. Cannot be combined with icIncremental. |
icIncremental | input | character | chr(2) seperated list of values to add to the fields of icFieldList. The same value(s) will be added in each record to update. Fields to update are restricted to data types integer and decimal. Cannot be combined with icAbsolute. |
ihClass | input | handle | Handle to the class that is using the persistence layer. In most of the cases, this handle will be available in the preprocessor {&TARGETPROCEDURE}. |
icUserLogin | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
if icIncremental <> "" then do: <M-4 run ReadDirect (input icTableName (icTableName), input icPrepare (icPrepare), input icFieldList (icFieldList), output vcCurrentValues (ocValueList), input ihClass (ihClass), output oiReturnStatus (oiReturnStatus)) in other> if oiReturnStatus <> 0 then return. end. &if defined(DEBUGSQL) > 0 &then run SqlDebugWrite in {&TARGETPROCEDURE} ("* ":U + program-name(1), 1). &endif run SqlBufCreate in {&TARGETPROCEDURE} (input icTableName, output viBufferId, output oiReturnStatus). if oiReturnStatus <> 0 then do: <M-1 run SqlErrorMessage (input ihClass (ihClass), output viFcReturnSuper (oiReturnStatus)) in other> return. end. do viCnt = 1 to num-entries(icFieldList): case entry(viCnt,icFieldListDataTypes): when "c":U then do: run SqlBufAddField in {&TARGETPROCEDURE} (input viBufferId, input entry(viCnt,icFieldList), input "character":U, input 0, output viFieldId, output oiReturnStatus). if oiReturnStatus = 0 then run SqlFldSetString in {&TARGETPROCEDURE} (input viBufferId, input viFieldId, input 1, input entry(viCnt,icAbsolute,chr(2)), output oiReturnStatus). end. when "d":U then do: run SqlBufAddField in {&TARGETPROCEDURE} (input viBufferId, input entry(viCnt,icFieldList), input "decimal":U, input 0, output viFieldId, output oiReturnStatus). if oiReturnStatus = 0 then do: if icIncremental = "" then vdValue = decimal(entry(viCnt,icAbsolute,chr(2))). else vdValue = decimal(entry(viCnt,vcCurrentValues ,chr(2))) + decimal(entry(viCnt,icIncremental,chr(2))). run SqlFldSetDecimal in {&TARGETPROCEDURE} (input viBufferId, input viFieldId, input 1, input vdValue, output oiReturnStatus). end. end. when "i":U then do: run SqlBufAddField in {&TARGETPROCEDURE} (input viBufferId, input entry(viCnt,icFieldList), input "integer":U, input 0, output viFieldId, output oiReturnStatus). if oiReturnStatus = 0 then do: if icIncremental = "" then viValue = integer(entry(viCnt,icAbsolute,chr(2))). else viValue = integer(entry(viCnt,vcCurrentValues ,chr(2))) + integer(entry(viCnt,icIncremental,chr(2))). run SqlFldSetInteger in {&TARGETPROCEDURE} (input viBufferId, input viFieldId, input 1, input viValue, output oiReturnStatus). end. end. when "l":U then do: run SqlBufAddField in {&TARGETPROCEDURE} (input viBufferId, input entry(viCnt,icFieldList), input "logical":U, input 0, output viFieldId, output oiReturnStatus). if oiReturnStatus = 0 then run SqlFldSetLogical in {&TARGETPROCEDURE} (input viBufferId, input viFieldId, input 1, input (entry(viCnt,icAbsolute,chr(2)) = "TRUE":U), output oiReturnStatus). end. when "t":U then do: run SqlBufAddField in {&TARGETPROCEDURE} (input viBufferId, input entry(viCnt,icFieldList), input "date":U, input 0, output viFieldId, output oiReturnStatus). if oiReturnStatus = 0 then do: vtemp = date(integer(substring(entry(viCnt,icAbsolute,chr(2)),5,2,"CHARACTER":U)), integer(substring(entry(viCnt,icAbsolute,chr(2)),7,2,"CHARACTER":U)), integer(substring(entry(viCnt,icAbsolute,chr(2)),1,4,"CHARACTER":U))). run SqlFldSetInteger in {&TARGETPROCEDURE} (input viBufferId, input viFieldId, input 1, input integer(vtemp), output oiReturnStatus). end. end. otherwise return. end case. if oiReturnStatus <> 0 then do: <M-2 run SqlErrorMessage (input ihClass (ihClass), output viFcReturnSuper (oiReturnStatus)) in other> return. end. end. run SqlBufWriteDirect in {&TARGETPROCEDURE} (input viBufferId, input icPrepare, output oiReturnStatus). if oiReturnStatus <> 0 then do: <M-3 run SqlErrorMessage (input ihClass (ihClass), output viFcReturnSuper (oiReturnStatus)) in other> end.