-
Is that possible to use INSERT, UPDATE or DELETE in WHEN-BUTTON-PRESSED, a button trigger? For example,
INSERT INTO TABLE (A) VALUES (:BLOCK.ID);
is that legal??
I do insert, but when I save I get an error message: 'record alread inserted' .... ???
I don't want to use DEFAULT&SMARTBAR for inserting data in my table, I want to do it with my own objects...
thanks in advance.
F.
-
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;
This would work.
Thanks, Deepa
-
if your requirement has more complex SQL statements, use the 'FORMS_DDL' package (which worke FINE with DML commands too) in the following way :
FORMS_DDL('INSERT INTO......');
FORMS_DDL('DELETE FROM.....');
FORMS_DDL('UPDATE .....');
Thanks, Deepa
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|