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

what is a join? : Sql dba

561


What is numeric function sql?

540


What is the need of a partition key?

530


What does trigger mean in slang?

525


Can we use pl sql in mysql?

517






What is substitution variable in pl sql?

501


What is serial sql?

522


Can you join a table to itself?

540


Explian rowid, rownum? What are the psoducolumns we have?

567


Write a query to find the names of users that begin with "um" in sql?

501


What is the cause of mutating table error and how can we solve it?

598


Is it possible to remove child records without removing master table records...the two having pk,fk relationship?

804


How do you declare a constant?

524


Write a sql query to get the third highest salary of an employee from employee_table?

632


Why stored procedures are faster than query?

566