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
How to fetch the row which has the max value for a column?
I creat Credit memo in AR. Now i want revers the Credit Memo.how you can revers that what out any aditional entry.
How to use "while" statements in oracle?
How many categories of data types in oracle?
What are the extensions used by oracle reports?
When system tablespace is created?
Will you be able to store pictures in the database?explain.
How to create a new tablespace in oracle?
Write a syntax for update query in oracle?
How to define default values for formal parameters?
How to export your own schema?
How to define a procedure inside another procedure?
Whats the benefit of dbms_stats over analyze?
Explain what are the type of synonyms?
How to get a list of all background sessions in the database?