首先将此程序创建为程序单元
PROCEDURE SYNC_BLOCK
-----------------------------------------------------------------------*
-- Synchronizes the display of any scrollable block.
-- After running an edit that loops through all records, this will
-- restore the block's display so that the same top record is again
-- at the top of the block's display.
-- Blk is the name of the block.
-- Rec_Num is the desired target current record.
-- Top_Rec is the original Top Record of the block captured
-- before the looping process began.
(BLK VARCHAR2,
REC_NUM NUMBER,
TOP_REC NUMBER) IS
BLK_ID BLOCK;
TOP_NEW PLS_INTEGER;
REC_N PLS_INTEGER;
--
Procedure Check_success is begin
If not form_success then
Raise form_trigger_failure;
End if;
End Check_success;
Procedure Go_Rec(rec_num number) is begin
Go_Record(Rec_num);
Check_Success;
End Go_Rec;
BEGIN
BLK_ID := FIND_BLOCK(BLK);
IF ID_NULL(BLK_ID) THEN
Message(' U72_GO_REC_SYNC_BLOCK: CANNOT FIND BLOCK '''||BLK||'''');
Raise Form_trigger_failure;
END IF;
IF BLK <> :SYSTEM.CURSOR_BLOCK THEN
GO_BLOCK(BLK);
Check_Success;
END IF;
IF :SYSTEM.CURSOR_RECORD <> REC_NUM THEN
GO_REC(REC_NUM);
END IF;
-- may need to re-set the display to the rows originally shown
TOP_NEW := GET_BLOCK_PROPERTY(BLK_ID, TOP_RECORD);
IF TOP_REC <> TOP_NEW THEN
IF TOP_REC < TOP_NEW THEN
IF :SYSTEM.CURSOR_RECORD <> TOP_REC THEN
GO_REC(TOP_REC);
END IF;
ELSE
REC_N := GET_BLOCK_PROPERTY(BLK_ID, RECORDS_DISPLAYED)
+ TOP_REC - 1;
IF :SYSTEM.CURSOR_RECORD <> REC_N THEN
GO_REC(REC_N);
END IF;
END IF;
SYNCHRONIZE;
-- Found that Sync caused focus change to different block. Fix here.
IF BLK <> :SYSTEM.CURSOR_BLOCK THEN
GO_BLOCK(BLK);
Check_Success;
END IF;
IF :SYSTEM.CURSOR_RECORD <> REC_NUM THEN
GO_REC(REC_NUM);
END IF;
END IF;
-- can't go_rec to NEW record, so need to test here
IF :SYSTEM.LAST_RECORD = 'TRUE'
AND REC_NUM = 1 + :SYSTEM.CURSOR_RECORD THEN
NEXT_RECORD;
Check_Success;
END IF;
--
END SYNC_BLOCK;
其次,下面的五行代码完全符合您的要求
xx:=GET_BLOCK_PROPERTY('blk',TOP_RECORD);
xxx:=GET_BLOCK_PROPERTY('blk',CURRENT_RECORD );
go_block('blk');
execute_query();
SYNC_BLOCK('blk',xxx,xx);
如果您需要更多信息,请随时与我联系