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

How to fetch the row which has the max value for a column?

984


I creat Credit memo in AR. Now i want revers the Credit Memo.how you can revers that what out any aditional entry.

2296


How to use "while" statements in oracle?

1300


How many categories of data types in oracle?

1009


What are the extensions used by oracle reports?

1024


When system tablespace is created?

1017


Will you be able to store pictures in the database?explain.

977


How to create a new tablespace in oracle?

968


Write a syntax for update query in oracle?

1013


How to define default values for formal parameters?

1024


How to export your own schema?

995


How to define a procedure inside another procedure?

999


Whats the benefit of dbms_stats over analyze?

1981


Explain what are the type of synonyms?

1094


How to get a list of all background sessions in the database?

972