Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the maximum limit on the number of columns in a table?

1151


Calculate difference between 2 date / times in oracle sql?

1097


How to drop a stored procedure in oracle?

1104


How to use subqueries with the in operator using oracle?

1137


How to display row numbers with the records?

1134


How to execute a stored procedure in oracle?

1147


What privilege is needed for a user to create tables in oracle?

990


ABOUT IDENTITY?

2109


what is normalisation?what are its uses?

2328


What is a dynamic performance view in oracle?

1057


How to connect ms access to oracle servers?

1056


What is an oracle tablespace?

1094


Explain drop constraint oracle?

1120


What is ASM (Automatic Storage Management) in Oracle?

1242


Differentiate between pre-select and pre-query?

1153