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 use having without group by in sql?

734


How much does sql cost?

735


Where the sql database files are stored?

696


Write the order of precedence for validation of a column in a table? I. Done using database triggers. Ii. Done using integarity constraints

848


What is sql trigger example?

754






What is null in pl/sql?

812


How do I view a view in sql?

702


Is sql better than excel?

705


Which software is used for pl sql programming?

684


What is triggering circuit?

772


Is sql workbench free?

719


What is the difference between inner join and outer join?

716


Does sql view stored data?

725


Can a table contain multiple foreign key’s?

745


How sql query is executed?

782