I tried the insert into in the when-button-pressed trigger and it blew up in my face.
This is what I use now and it works fine for me.
It allows me to check for duplicates with my own customized message.
declare
cnt number;
begin
select count into cnt from my_table
where my_id = :block.my_id;
if cnt > 0 then
message('Record already exists for this id');
message('Record already exists for this id');
raise form_trigger_failure;
end if;
commit_form;
end;
************************
This is my delete statement
begin
set_alert_property('Yes_No',alert_message_text,'Are You Sure You Want To Delete?');
if show_alert('Yes_No')=Alert_Button1 then
Delete from my_table
where my_id = :block.my_id;
end if;
exception
when no_data_found then
message('No records found to be deleted');
message('No records found to be deleted');
raise form_trigger_failure;
end;
This means that you have to create an alert name in object navigator.
********************************
Update works like regular update statement.
Instead of manipulating code in the above ways, here is the simplest solution :
1. Have 2 blocks on your form : data block, and buttons block.
2. On the WHEN-BUTTON-PRESSED trigger on button residing on the buttons block, write :
next_block:
create_record;
Bookmarks