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...

how do you restrict number of rows for a particular value
in a column.For example:there is a table called
fruits,having apples,bananas ,papayas.I dont want to have
more than 100 apples in that table ,so how can u restrict
number of rows for apple to hundred?

Answer Posted / bikash khuntia

We have to create a trigger for that which is one of the
way for the solutuion as below:-

create or replace trigger trigger_name
before insert on table_name
for each row
DECLARE
v_count number;
begin
select count(apple) into v_count from table_name;
if v_count=100 then
raise_application_error('-20011','u cant insert more than
100 apples in the table');
end if;
end;

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we create foreign key without primary key?

933


What is the difference between cluster and non-cluster index?

1050


what is index? : Sql dba

945


What is normalization in a database?

1107


Can we use delete in merge statement?

1002


How to create your own reports in sql developer?

976


Why is a primary key important?

967


How to run sql statements through the web interface?

986


Why do we use cursors?

921


Name the operator which is used in the query for pattern matching?

894


GLOBAL TEMPORARY TABLE over Views in advantages insolving mutating error?

3010


What is the difference between the implicit and explicit cursors?

994


What is the main difference between sql and pl/sql?

1028


Does inner join return duplicate rows?

930


Explain what is a subquery ?

1124