Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to restrict only one row in Table ??.

107862Aug 23 2004 — edited Aug 23 2004
Hi all,
i want to restrict no. of rows to one,
that is not more that one row should be there in the table.

Following trigger works well in all conditions
except:
insert into myTab select 'x' from emp;

inserts 14 rows.

Create or replace trigger one_row_myTab
before insert on myTab
for each row
declare
cnt number;
pragma AUTONOMOUS_TRANSACTION;
Begin
select count(*) into cnt from mydual;
if cnt=1 then
raise_application_error(-20001,'MyDual Can have only one Row');
end if;
end;

i think with trigger it w't be possible because,
same transaction triggers c't query the table (Mutating Table),
Autonomus trans ca't identify uncommited changes.

pls add your suggestions.

Thanks for Reading the Post.

Rajashekhar Ganga,
mail : rs_ganga@yahoo.com
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2004
Added on Aug 23 2004
11 comments
273 views