Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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?

Answers were Sorted based on User's Feedback



how do you restrict number of rows for a particular value in a column.For example:there is a table..

Answer / gk

We can use Check constraint to restict the values of any
column.

Is This Answer Correct ?    12 Yes 3 No

how do you restrict number of rows for a particular value in a column.For example:there is a table..

Answer / suresh babu

create check constraint is the best way to restrict the
limited number of entries,because the constraint won't take
a separate space,but Trigger required separate memory
space.perhaps the trigger got error,it would affect all
entries in table.

Is This Answer Correct ?    2 Yes 1 No

how do you restrict number of rows for a particular value in a column.For example:there is a table..

Answer / guest

hint:using row level and statement level trigger

Is This Answer Correct ?    1 Yes 1 No

how do you restrict number of rows for a particular value in a column.For example:there is a table..

Answer / 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

how do you restrict number of rows for a particular value in a column.For example:there is a table..

Answer / ashwin

You can create a sequence named seq_fruit as below .

create sequence seq_fruit
increment by 1
start with 1
maxvalue 100
minvalue 1
cycle
cache 10
if the current count ie currval of seq_fruit is 100 and
after this if u r inserting a new row in fruit table as
following

insert into fruit values(seq_fruit.nextval,30,40);
after the execution of this statement next value for apple
will be entered as 1 and not 101.

The cycle keyword will avoid the count of fruit column to go
beyond 100.

Is This Answer Correct ?    0 Yes 1 No

how do you restrict number of rows for a particular value in a column.For example:there is a table..

Answer / xyz

aLTER TABLE emp ADD CONSTRAINT C3 CHECK (EMPNO < 300)

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More SQL PLSQL Interview Questions

Which one is the Best approach to put code, among Triggers and Procedures? Explain?

1 Answers   Sierra Atlantica,


What is sql engine in oracle?

0 Answers  


what is a constraint? Tell me about its various levels. : Sql dba

0 Answers  


Is sql a dbms?

0 Answers  


What are the two different parts of the pl/sql packages?

0 Answers  


What are the two parts of a procedure ?

6 Answers   Hi Caliber IT,


What is a scalar value in sql?

0 Answers  


I need to write a simple query,which one is better select statement or stored procedure?and why?

2 Answers   iGate,


How many columns should be in an index?

0 Answers  


What are the most important ddl statements in sql?

0 Answers  


What is rowtype?

0 Answers  


Can procedure in package be overloaded?

0 Answers   EXL,


Categories