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
Can we create foreign key without primary key?
What is the difference between cluster and non-cluster index?
what is index? : Sql dba
What is normalization in a database?
Can we use delete in merge statement?
How to create your own reports in sql developer?
Why is a primary key important?
How to run sql statements through the web interface?
Why do we use cursors?
Name the operator which is used in the query for pattern matching?
GLOBAL TEMPORARY TABLE over Views in advantages insolving mutating error?
What is the difference between the implicit and explicit cursors?
What is the main difference between sql and pl/sql?
Does inner join return duplicate rows?
Explain what is a subquery ?