Consultor Eletrônico



Kbase P74503: How to delete all the records returned by a smartFilter
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   31/03/2004
Status: Unverified

GOAL:

How to delete all the records returned by a smartFilter

GOAL:

How to delete all the records returned by a SDO query

FIX:

The following code show how to delete all the records returned by an SDO query. This code is handy when a smartFilter is used. In this way you can implement a mechanism that delete all the result that comes from a smartFilter
You can have just a SDO and a BUTTON for the trigger code. You can also have a SmartDataBrowse to view the records you want to delete.

The sample code:

ON CHOOSE OF BUTTON-1
DO:
DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE hquery AS HANDLE NO-UNDO.
DEFINE VARIABLE vRowIdent AS CHARACTER NO-UNDO.
DEFINE VARIABLE vLocalRowIdent AS CHARACTER NO-UNDO.

hquery = DYNAMIC-FUNCTION('getQueryHandle':U IN h_dtable).

hbuffer = hquery:GET-BUFFER-HANDLE().
hquery:GET-FIRST().

/*you may want to include this in a single transaction*/
REPEAT WHILE hbuffer:AVAILABLE.
/*the following 4 statements will delete the record*/
ASSIGN vRowIdent = DYNAMIC-FUNCTION('getRowident' IN h_dtable).
DYNAMIC-FUNCTION('fetchrowident' IN h_dtable, vRowIdent, "").
ASSIGN vLocalRowident = ENTRY(1,
DYNAMIC-FUNCTION('colValues' IN h_dtable,""), CHR(1)).
DYNAMIC-FUNCTION('DeleteRow' IN h_dtable, vLocalRowIdent).

hquery:GET-NEXT().
END.

DYNAMIC-FUNCTION('openQuery':U IN h_dtable).
END.