t1
col1 col2
nishi 5000
lucky 6700
akash 7000
i want that a query that when i insert 7000 it will show me data already present and data will not insert. if data is not present it will insert.
Answer Posted / uday
The best thing would be to create a trigger which checks and not allows duplicate data .
Create or replace trigger trig1
before insert or update on t1
for each row
declare
a number (10);
begin
select count(*) into a from t1 where col2 = :new.col2;
if a >= 1 then
raise_application_error(-20123,'data already present and data will not insert');
elsif a = 0 then
dbms_output.put_line('inserted');
end if;
end;
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is pragma autonomous transaction in oracle?
What is the difference between 10g OEM and 11g OEM?
how to clone 9i Database on to 10g Database.
Why is oracle so popular?
What is the difference between sharding and replication?
What is oracle analytical function?
What is an oracle database table?
Describe varray?
How to update values in a table in oracle?
What privilege is needed for a user to create tables in oracle?
How to convert dates to characters in oracle?
Why use resource manager in Oracle?
How to create an oracle database?
6. Display the client name and order date for all orders using the traditional method.
What is connection pooling in oracle?