-
How to insert values
How to insert values?
I have on table having four columns,
There is no primary Key to table.
There are some records in the table
Now I am inserting new records, but before insertion, I wants to verify If the records with same values is present in table or not? If it is , then insertion will not be done. else record shall be inserted. I m thinking about triggers. When I use insert option, table is get lock & I am not able to use it.
So I request all to guide me.
-
Re: How to insert values
You can do the same with help of a procedure. Before inserting data to the table check for count of that record in the specified field. If count returns 0 then only insert else raise some error message.
-
Re: How to insert values
Follow this sample trigger
CREATE OR REPLACE TRIGGER emp_tri before insert on emp for each row
declare
x char;
begin
begin
select 'X' into x from dual where exists (select * from emp where empno=:new.empno);
exception
when no_data_found then
x:=null;
end;
if nvl(x,' ')='X' then
raise_application_error(-20000,'Data already entered');
end if;
end;
-
Re: How to insert values
Thank u...
But I get the values (to be insert) from system, automatically,after each 5 mins. & before inserting these values I wants to check whether these values are present in table if they r, then not permit them to insert. else insert them in table
-
Re: How to insert values
[QUOTE=RupeshDharne;22170]How to insert values?
I have on table having four columns,
There is no primary Key to table.
There are some records in the table
Now I am inserting new records, but before insertion, I wants to verify If the records with same values is present in table or not? If it is , then insertion will not be done. else record shall be inserted. I m thinking about triggers. When I use insert option, table is get lock & I am not able to use it.
So I request all to guide me.[/QUOTE]
Dear RupeshDharne,
If you want to do this using trigger then it will not possible to do the same
because while writing trigger on a table, you cannot use the DML on the same
table. It will give Mutating error.
You can do this at Form Level as follows:
Suppose you have 4 columns
A B C D
consisting some data.
Now before applying any DML you check first whether the values in
the Text boxes or variables in your form, are there in your table or not.
You can do this by using SELECT statement.
Try this and reply if problem persists.
Have a pleasant time