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 sql server agent? : Sql dba
What is the use of function in sql?
What are the types of subqueries?
What are the different types of triggers?
How to return multiple rows from the stored procedure?
What is thread join () in threading?
What are different joins used in sql?
What is rank () in sql?
What is the clause we need to add in function body to return variable?
What do you know by pl/sql cursors?
Does a primary key have to be a number?
What is the difference between delete and truncate statement in sql?
What is the plv (pl/vision) package offers?
What are field types?
what is bcp? When does it used? : Sql dba