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
Name the three major set of files on disk that compose a database in Oracle?
what are bitmap indexes? How does they work?
What are the benefits of ordbms?
How to invoke the data pump export utility?
What is translate in oracle?
What is oracle latest version?
What is the difference between post-database commit and post-form commit?
What is BBED in Oracle?
In which language oracle has been developed?
1) What is ONE_SIZE_FITS_ALL approach? 2) Explain the Common & Variable Header of DATA FILE? 3) What are the Drawbacks to using OMF DB? and the Advantages? 4) List out the Advantages of Undo T.spaces over the Undo SEGMENT? 5) Difference between the Temporary tablespace with TEMPFILE and the Tablespace with TEMPORARY Keyword? 6) What are the situation extents are freeing for reuse.
What is the difference between I and G in Oracle?
Explain about achiever in sql?
What is an index associated with a constraint?
does the query needs a hint to access a materialized view?
What language does oracle use?