I couldn't reproduce your error, but one problem is that CM.CUSTOMER can't be both a table and a sequence.
Generally it is best practice not to hardcode schema names unless you really have to. I would prefer to leave out the schema name here and just run it from the CM account.
I created a sequence named customer_seq and the following runs without error:
create table customer
( id number primary key
, first_name varchar2(20)
, last_name varchar2(20)
, status number );
create sequence customer_seq;
declare
status varchar(10) := '10';
loop_size number := 10;
begin
while loop_size > 0
loop
insert into customer (id, first_name, last_name, status)
values (customer_seq.nextval, 'Jhon', 'Jhon', status);
loop_size := loop_size -1;
end loop;
end;
/
If using Oracle 12.1 or later I would prefer to use an identity column and stop micro-managing sequences. You also don't need to manage the loop index yourself as PL/SQL has a convenient for loop construct:
create table customer
( id number generated always as identity primary key
, first_name varchar2(20)
, last_name varchar2(20)
, status number );
declare
status varchar(10) := '10';
loop_size number := 10;
begin
for i in 1..loop_size loop
insert into customer (first_name, last_name, status )
values ('Jhon', 'Jhon', status);
end loop;
end;
/
CMis? A schema? What user runs this?CMaccount. (By the way, you have astatusvariable but you don't use it. Is it a sting or a number?)