Forms :: Delete A Record By Writing Code In When_button_pressed Trigger
May 4, 2010How can I delete a record by writing code in when_button_pressed trigger.
View 8 RepliesHow can I delete a record by writing code in when_button_pressed trigger.
View 8 Repliesthe following case is successfully done with mssql databases.
Case:
Table UserGroup
Columns id, name, handshake
When the handshake is set to 'd', this record should be deleted. I know it is bad behaviour by design.
What have I done so far:
- created an after update trigger (mutual error) Caused by trying a delete action in the update action, not possible.
- created a view in combination of instead of update trigger.
This causes also mutual error, or if ignored (PRAGMA AUTONOMOUS_TRANSACTION), an deadlock.
Code so far:
create or replace procedure Delete_UserGroup_sp(p_groupId in USER_GROUP.HMIUSERGROUPID%TYPE, p_handshake in USER_GROUP.HANDSHAKE%TYPE)
is
begin
if p_handshake = 'd' then
delete USER_GROUP WHERE HMIUSERGROUPID = p_groupId;
commit;
end if;
end;
create or replace view USERGROUP_V as select * from USER_GROUP
create or replace trigger USER_GROUP_T1
instead of update on USERGROUP_V
for each row
declare
PRAGMA AUTONOMOUS_TRANSACTION;
begin
Delete_UserGroup_sp(:new.HMIUSERGROUPID, :new.HANDSHAKE);
end;
i have one table ot_ins_item where user will enter the details of item, grade,item qty , later on user will go and update the same table the details of different grades received for the same item in different columns with qty breakup in 3 different fields it_qty_01 , it_qty_02,it_qty_03 respectively with different grades , what i need is i want is whenever he updates this table with different grades based on data entered in 3 different fields , a procedure or trigger should delete the initial record saved and insert three different rows based on newly updated values , it may be 3 or it may be 2 sometime depending upon input values that many records should be inserted same time controlling the qty's entered in breakup not exceeding the main qty.
CREATE TABLE ot_ins_item (it_ins_no NUMBER,it_no NUMBER,it_grade VARCHAR2(12),
it_code VARCHAR2(12),it_qty NUMBER,it_flex_01 VARCHAR2(12),
it_01_qty NUMBER,it_flex_02 VARCHAR2(12),it_02_qty NUMBER,it_flex_03 VARCHAR2(12),
it_03_qty NUMBER);
create sequence s_it_no start with 1 ;
INSERT INTO OT_INS_ITEM VALUES (1,s_it_no.NEXTVAL,'A','ITEM1',NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO OT_INS_ITEM VALUES (1,s_it_no.NEXTVAL,'B','1TEM2',NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO OT_INS_ITEM VALUES (1,s_it_no.nextval,'C','ITEM3',NULL,NULL,NULL,NULL,NULL,NULL);
SELECT * FROM OT_INS_ITEM;
[code]....
I have a problem in running a sql query.I have a dataset with the following details. Product name,product status,approval date in table product_details. I have a code as follows
select Product_name,
Product_status,
approval_date,
case
when product_status ='Cancelled' or product_status ='Stopped' then approval_date='N/A'
when product_status='Active' then NVL2(approval_date,cast(appoval_date as nvarchar2(30)),'Null')
when product_status='Completed' then NVL2(approval_date,cast(appoval_date as nvarchar2(30)),'Null1')
when product_status='Planned' then NVL2(approval_date,cast(appoval_date as nvarchar2(30)),'Null2')
end as DER_approval_date
from product_details
but i have a error in running this code saying character mismatch.
I have data some thing like this.
NO NAME LOC SAL
------------------------------------------------------------------
1 A HYD 100
2 B BGL 200
1 A HYD 200
1 A HYD 150
I want to delete duplicate records (group by no,name,loc) but only max(qty) record should be retained. So I need output like this.
NO NAME LOC SAL
------------------------------------------------------------------
1 A HYD 200
2 B BGL 200
i want to fetch the data in my form from table, by using item_code.
eg when i write the item_code its value get matched in same table and fetch the another
columns by item_code.
i m using oracle 10g forms
in one form
there are multiple records shown in this form
i m using one delete button
coding is
declare
v_yes_no varchar2(1);
begin
v_yes_no:=display_alert2('alert_2','Caution','Do you want to delete current record');
[Code]...
but when i press this button then one message shown on secreen
you can not delete this record
when i debug the form
message shown through on error trigger
i can not understand why this message ocuured
and record not deleted
no any constraint use in this form
but if i delete record from backend then records delete successfully
when i tried to delete the record by clicking the delete button which has the trigger code as
delete from emp where employee_id=:e_id; commit;
it wasn't. and showed the message as
---FRM-40508: ORACLE ERROR: Unable to INSERT record.
if i change the EMP ID item property "database item" to "NO"..then i can able to delete the record..but, now i am unable to insert the record form the same form...
this is just the continuation of my previous topic,
After I bound data into the textboxes, now I want to delete it when I mistakenly click on the same data twice.
this is my screenshot:
How can I delete a record simultaneously to table?
View 30 Replies View RelatedI am using 10g and want to let an user to delete a single record from a multirow form via delete button. This button is supposed to do the same, what the "delete record" button on the default menu does. (I want a custom menu, so I can't use that button)
My delete button ist assigned to a control-block and the when-button-pressed-Trigger of that button looks like this:
-------------
DECLARE
TEMP VARCHAR(30);
BEGIN
-- Record chosen?
IF :<BLOCK>.ID IS NOT NULL THEN
[Code]...
The problem is, that the alert asks the user about the previously chosen record correctly, but if the user clicks BUTTON1 the Form says: No changes to save (FRM-40401).
when a user change or delete any record or row in forms data automatically move to other table because i want to compare old and new record.
View 8 Replies View RelatedMy form consist two datablock cust_mstr,cust_dtls, each customer code consists two or three contact details records, when i delete the single detail record instead of deleting single record it deletes all the details records from cust_detail table.
Here by i attaching my form for your reference pls find the code in delete button
i m using oracle 10g forms. in one form i m using post keyword when i use this function then records saved in temporary database but i want to remove one record from this form but it is allrady saved through post.
View 1 Replies View RelatedI have multirecord block and I want to disable Inserting/Updating/Deleting more then one record at a time.
View 32 Replies View RelatedI have develop the New Form.Their as a Validate require to Include in it.without saving the Current Record, it not allow to enter the New Record.
Which Trigger Used for this Validate and How to done it.
I am trying to write a procedure using when-validate-record that will clear all fields, display a message and ignore all commits if user is not authorized to have access to make changes to the form.
I have tried to use Clear_form(no_validate)and clear_record and neither works
I am navigating from a Master form to a child form. The when-create-trigger in the child form is sometimes executing and sometimes not. Not firing of this trigger is causing the child form to open without any initially assigned values. What is the root cause and also the scenarios where the when-create-trigger fires.
View 15 Replies View RelatedI am developing form, but there is issue when I Press F11 to query data.I make trigger form when-new-record-instance to assign values for item.But when i Press F11 then Block no clear.
View 1 Replies View RelatedUsing 11gR2, windows 7 client machine. I need to update the table missing_volume (below), where I need to calculate the estimated_missing column. The calculation of estimated_missing column for current month needs previous month numbers (as commented inside the code below). I want the output like the first table. Notice the records start from January, hence estimated_missing for January can't be calculated, but for the the rest of the months it can be done by simply changing 'yr' and 'mnth' (commented inside the code towards the end).
yr mnth location volume actual_missing expected_missing estimated_missing
---------------------------------------------------------------------------------------------------------------------------------
2013 January loc1 48037 24 57
2013 February loc1 47960 3660 53 24
2013 March loc1 55007 78 57 28
2013 April loc1 54345 72 58 77The code:
UPDATE missing_volume g
[Code]....
The code does calculate correct number for 'estimated_missing' as I run the code for each month, but the problem is while updating the current month it also erases the record for previous month. E.g. as can be seen below, after I updated April the column only has the record for April, previous month record is gone, similarly updating March removed February, etc. I can't understand why it's happening!! Here is the output I get:
yr mnth location volume actual_missing expected_missing estimated_missing
---------------------------------------------------------------------------------------------------------------------------------
2013 January loc1 48037 24 57
2013 February loc1 47960 3660 53
2013 March loc1 55007 78 57
2013 April loc1 54345 72 58 77
why it's happening (I mean where is the flaw in the code) and how to get the desired output (first table).
I have a multi record control block (basically a text item displaying 6 records) where user enters values and I want to process the values using pre-insert trigger.
I want to read value in each record and then do some tasks using a pre-insert trigger before I commit the values. To navigate between the records I was using first_record, next_record, clear_record built-ins but it gives errors like "40737-illegalrestricted procedure next_record in pre-insert trigger".
Well I need to make a trigger that don't allow delete departments in the next 3 month.
I dont know how to start it :/
I want to delete the duplicated record using following methods, it delete the records if all the record are matched according to condition, but if all records are not matched then it display error messages.
SQL> SELECT * FROM XYZ;
NAME FNAME ADDRESS JOB
-------------- -------------------- -------------------- -----------------------------------------
Bilal Khan Wali your rehman name district abbottabad student
Bilal Khan Wali your rehman name district abbottaba student
Bilal Kh Wali your rehma name district abbotta studen
Bilal K Wali your rehm name district abbotta studen
Bilal Khan Wali your rehman name istrict abbottaba tudent
lal Khan i your rehman name strict abbottaba tudent
[code]....
I have tried the following delete statement but it is taking long time,and it's not giving any result.
DELETE FROM hs_table WHERE sno=1234 and effdt='25-MAY-10';
The records in the table are 90000.And we are deleting only one report.
I have a requirement to delete duplicate records. For example,if the below query retrieves count of duplicate records along with the column values.
select col2,col3,col4,col5,col6,col7,count(*) from table
group by
col2,col3,col4,col5,col6,col7
having count(*) > 1;
I would like to retain only one record with max(col1) which is a surrogate key and other records should be deleted.How to retain one record in a duplicate record set based on max of certain column.
I would like to create a trigger that will execute a stored procedure when a package/function/procedure is compiled. I tried creating an update trigger on user_objects, but it statues aI cannot create that trigger tyoe on views.
View 1 Replies View RelatedI'm trying to install forms 10g on my windows 2000 professional os which is having oracle 9i client. but while installing 10g i'm geting oracle universal installer error. error in writing to directory c:...
My D drive is having 10GB free space and C drive is having 800MB free space (both drive have normal attribute i.e it's not read only ) and oracle have already copied some temp files in C drive (size 13.6 MB) .
The Scenario is that we have to restrict clients to write file on C drive for which we have to grant admin privileges(OS) which we don't wanna give. Rather they can write on their own profile.
In CMD we can find their profile with %userprofile% command,but i am confused of using it in oracle form. so is there any possibilities to redirect O/P to userprofileyour_file.txt
Just for an instance ,code is like this which is currently writing in C: drive
Declare
in_file TEXT_IO.FILE_TYPE;
linebuf VARCHAR2(80);
your_file VARCHAR2(50) := 'C:TEMPyour_file.dat';
text_line VARCHAR2(400);
[code].......
how to delete Parent table records without affecting to child table dependent records?..
View 5 Replies View RelatedI have written this below code. The logic behind the code is, Delete the duplicate record from a table, and delete those record from other 7 table based on the SL_NUMBER.
But Problem is After delete the duplicate record When I have use Below statement
RETURNING SL_NUMBER BULK COLLECT INTO rec_sl_number;
This statement unable to return approx 40 Lakhs SL_NUMBER
DECLARE
rec_sl_number dbms_sql.number_table;
BEGIN
[Code]....