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
what is a join? : Sql dba
What is numeric function sql?
What is the need of a partition key?
What does trigger mean in slang?
Can we use pl sql in mysql?
What is substitution variable in pl sql?
What is serial sql?
Can you join a table to itself?
Explian rowid, rownum? What are the psoducolumns we have?
Write a query to find the names of users that begin with "um" in sql?
What is the cause of mutating table error and how can we solve it?
Is it possible to remove child records without removing master table records...the two having pk,fk relationship?
How do you declare a constant?
Write a sql query to get the third highest salary of an employee from employee_table?
Why stored procedures are faster than query?