Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## update-auditing-policies procedure

> Save the audit policy changes tracked in a specified ProDataSet object into a specified target database. The caller should check the ProDataSet and buffer's `ERROR` attribute for any error conditions and the buffer's `ERROR-STRING` for error messages.

> Parameters:

> `INPUT pcDbInfo AS CHARACTER`

> Database information string specifying the target database to save the changes.

> `INPUT-OUTPUT DATASET-HANDLE phDataset`

> ProDataSet with the tracked changes.

> Note: This procedure calls the `_update-policies.p` external procedure, which automatically refreshes the database cache by calling the `AUDIT-POLICY:REFRESH-AUDIT-POLICY()` method.

> Example: The following example is a combination of pseudo-code and 4GL that shows how to run this procedure:

> Calling the update-auditing-policies API procedure
>     {auditing/include/_aud-utils.i}
>     DEFINE VARIABLE hDSChanges AS HANDLE NO-UNDO.
>     DEFINE VARIABLE hQuery     AS HANDLE NO-UNDO.
>     DEFINE VARIABLE hBuffer    AS HANDLE NO-UNDO.
>     DEFINE VARIABLE i          AS INT    NO-UNDO.
>     DEFINE VARIABLE cStatus    AS CHAR   NO-UNDO INIT "".
>     DEFINE VARIABLE errorMsg   AS CHAR   NO-UNDO.
>     /* turn tracking-changes off for now */
>     RUN set-tracking-changes (INPUT NO).
>     /* create a ProDataSet with the changes before sending
>        it to the other procedure */
>     CREATE DATASET hDSChanges.
>     hDSChanges:CREATE-LIKE(hAuditDset).
>     hDSChanges:GET-CHANGES(hAuditDset). /* get the changes */
>     ASSIGN errorMsg = "".
>     /* call the generic procedure passing our local ProDataSet */
>     RUN update-auditing-policies IN hAuditUtils  (INPUT cDbInfo,
>                           INPUT-OUTPUT DATASET-HANDLE hDSChanges BY-REFERENCE).
>     ASSIGN errorMsg = RETURN-VALUE.
>     /* turn tracking changes back on */
>     RUN set-tracking-changes (INPUT YES).
>     /* Check the ERROR status that might have been returned. */
>     IF errorMsg = "":U AND hDSChanges:ERROR THEN
>     DO:
>         /* There was an error somewhere in the updates. Find it. */
>         DO i = 1 TO hDSChanges:NUM-BUFFERS.
>             CREATE QUERY hQuery.
>             hBuffer = hDSChanges:GET-BUFFER-HANDLE(i):BEFORE-BUFFER.
>             hQuery:ADD-BUFFER(hBuffer).
>             hQuery:QUERY-PREPARE("FOR EACH " + hBuffer:NAME).
>             hQuery:QUERY-OPEN().
>             hQuery:GET-FIRST().

>             DO WHILE NOT hQuery:QUERY-OFF-END:
>                 IF hBuffer:ERROR THEN
>                     cStatus = cStatus + hBuffer:ERROR-STRING + CHR(10) NO-ERROR.
>                 hQuery:GET-NEXT().
>             END.
>             hQuery:QUERY-CLOSE().
>             DELETE OBJECT hQuery.
>         END.

>     END.
>     /* delete the ProDataSet with changes */
>     DELETE OBJECT hDSChanges.
>     IF errorMsg <> "":U THEN
>         RETURN errorMsg.
>     IF cstatus = "" THEN
>         /* if no errors so far, accept all the changes */
>         hAuditDset:ACCEPT-CHANGES().
>     ELSE
>        RETURN cstatus.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095