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
Explain the use of Merge statement in oracle 11g
how may join possible between (requisition with purchase order)
State the various uses of dbcc command?
How to loop through data rows in the implicit cursor?
Explain the use of rows option in exp command.
What do you mean by cdb and pdb in oracle 12c?
What happens in oracle commit?
How to pass parameters to procedures?
Difference between varchar and varchar2 data types?
How to add a new column to an existing table with a default value?
How does oracle handle read consistency?
What is PL/SQL ?
why dont we assign not null constraint as table level constraint.
Does oracle partitioning improve performance?
How to experiment a data lock in oracle?