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 pragma autonomous transaction in oracle?

1070


What is the difference between 10g OEM and 11g OEM?

965


how to clone 9i Database on to 10g Database.

2339


Why is oracle so popular?

997


What is the difference between sharding and replication?

1048


What is oracle analytical function?

1143


What is an oracle database table?

1015


Describe varray?

1058


How to update values in a table in oracle?

1026


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

953


How to convert dates to characters in oracle?

1041


Why use resource manager in Oracle?

1105


How to create an oracle database?

1041


6. Display the client name and order date for all orders using the traditional method.

2306


What is connection pooling in oracle?

973