i have a form for creating customers and in this form i have a field that is a LOV showing the customer types and depending on this customer there will be needed a specific document for him,so i have a button to get these documents related to this customer type.
but i have a problem when i want change the customer type before saving and press on the customer documents button again it gives me the documents again plus the ones already there.and in this case it doesn't allow me to save because the constraint on the documents .

i need to write a code that check if the document are there to not allow me to get them again.and if there is a new document need to be added for the old ones just this one should be added not all of them again but this code is creating them all over and over again

procedure create_doc_records is
cursor c1 is select * from docs where cust_type = :block.cust_type;
go_block (x);
for r1 in c1 loop
if :system.record_status != 'NEW' then
end if;
:docs.base := :block.base;
:docs.doc_type := r1.doc_type ;
:docs.date := 'N';
:ai_docs.viewed := sysdate;

end loop;

when others then


if any one can help me in this issue and if you have a similar form example.i will really appreciated.