Consultor Eletrônico



Kbase 21465: How To Use INSERT-ROW Method Within an Empty Browser
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   21/11/2008
Status: Verified

GOAL:

How to use the INSERT-ROW Method against an empty browser?

GOAL:

Why INSERT-ROW Method against a physical Table leads to Error 382?

GOAL:

Using INSERT-ROW Method against an Empty Browser

GOAL:

Using INSERT-ROW Method against a physical Table

GOAL:

Invalid use of browse method . There are no selected rows. (382)

FACT(s) (Environment):

Windows
Progress 8.x
Progress 9.x
OpenEdge 10.x

FIX:

If you use the INSERT-ROW against a physical table and you do not open the query so that you have an empty browser, this will result into error 382.
This error happens because the query has not been opened.
To avoid this from happening, create a TEMP-TABLE like the physical Table but do not populate the TEMP-TABLE with records.
The code below demonstrates this strategy.

DEFINE TEMP-TABLE MT LIKE ITEM.

DEFINE QUERY q1 FOR MT SCROLLING.

DEFINE BROWSE b1 QUERY q1
DISPLAY itemnum itemname price
ENABLE itemname price
WITH 10 DOWN SEPARATORS TITLE "Update Inventory".

DEFINE VARIABLE method-status AS LOGICAL NO-UNDO.
DEFINE VARIABLE temp-rowid AS ROWID NO-UNDO.

DEFINE BUTTON b-new LABEL "Add New Record" SIZE 45 BY 1.5.

DEFINE FRAME f1
b1 SKIP b-new WITH SIDE-LABELS ROW 2 CENTERED NO-BOX.

ON CHOOSE OF b-new
DO:
method-status = b1:INSERT-ROW("After").
END.

ON ROW-LEAVE OF BROWSE b1
DO:
IF b1:NEW-ROW IN FRAME f1 THEN
DO ON ERROR UNDO, RETURN NO-APPLY:
CREATE MT.
ASSIGN itemnum = NEXT-VALUE(nextitemnum)
INPUT BROWSE b1 itemname price.
method-status = b1:CREATE-RESULT-LIST-ENTRY().
END.
END.

OPEN QUERY q1 FOR EACH MT NO-LOCK.

ENABLE ALL WITH FRAME f1.

WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.