Hello,
Because I'am working on a project where it is needed to duplicate non adjacent records, I developped a COPY_RECORD procedure:
The needed things:
A block containing a 'source' record you want to duplicate and a dest record IN THE SAME BLOCK to want to populate with the data of the source.
First You HAVE TO
GO_BLOCK('BLOCK');
CREATE_RECORD;
lRecordCreated := :SYSTEM.CURSOR_RECORD; -- To know where you are
:BLOCK.Field := VALUE; -- Populate a field of the created record so form will not drop it when the COPY_RECORD navigates between records.
Then
COPY_RECORD(lSourceRecord, lRecordCreated);
...
Copy_record is :
For now, it copies all fields via a varchar2 convertion, this could be changed to better manage data, bur this is
So, I hope this can help some of you.
Because I'am working on a project where it is needed to duplicate non adjacent records, I developped a COPY_RECORD procedure:
The needed things:
A block containing a 'source' record you want to duplicate and a dest record IN THE SAME BLOCK to want to populate with the data of the source.
First You HAVE TO
GO_BLOCK('BLOCK');
CREATE_RECORD;
lRecordCreated := :SYSTEM.CURSOR_RECORD; -- To know where you are
:BLOCK.Field := VALUE; -- Populate a field of the created record so form will not drop it when the COPY_RECORD navigates between records.
Then
COPY_RECORD(lSourceRecord, lRecordCreated);
...
Copy_record is :
Code:
PROCEDURE COPY_RECORD(vSource NUMBER, vDest NUMBER) IS
lItem VARCHAR2(30);
lValue VARCHAR2(1000);
BEGIN
lItem := GET_BLOCK_PROPERTY(:SYSTEM.CURSOR_BLOCK, FIRST_ITEM);
LOOP
IF GET_ITEM_PROPERTY(:SYSTEM.CURSOR_BLOCK||'.'||lItem, ITEM_TYPE) != 'BUTTON' THEN
GO_RECORD(vSource);
lValue := NAME_IN(:SYSTEM.CURSOR_BLOCK||'.'||lItem);
IF lValue IS NOT NULL THEN
GO_RECORD(vDest);
Synchronize;
COPY(lValue, :SYSTEM.CURSOR_BLOCK||'.'||lItem);
END IF;
ELSE
IF GET_ITEM_PROPERTY(:SYSTEM.CURSOR_BLOCK||'.'||lItem, ITEM_TYPE) != 'BUTTON' THEN
MESSAGE('I don't know how to copy objects like ' ||GET_ITEM_PROPERTY(:SYSTEM.CURSOR_BLOCK||'.'||lItem, ITEM_TYPE));
END IF;
END IF;
EXIT WHEN lItem = GET_BLOCK_PROPERTY(:SYSTEM.CURSOR_BLOCK, LAST_ITEM);
lItem := GET_ITEM_PROPERTY(:SYSTEM.CURSOR_BLOCK||'.'||lItem, NEXTITEM);
END LOOP;
END;
For now, it copies all fields via a varchar2 convertion, this could be changed to better manage data, bur this is
So, I hope this can help some of you.