I am having PLS-00103: Encountered the symbol - oracle

i am having
PLS-00103: Encountered the symbol "END" when expecting one of the
following: ( begin case declare exit for goto if loop mod null
pragma raise return select update while with << continue
close current delete fetch lock insert open rollback savepoint set
sql execute commit forall merge pipe purge error
and i have searched everywhere but couldnt find how to solve
CREATE TABLE UPAYMENT AS SELECT * FROM PAYMENT ;
DROP TRIGGER A;
CREATE OR REPLACE TRIGGER A
after insert ON Upayment
FOR EACH ROW
DECLARE
ERROR_ EXCEPTION ;
h varchar2(20);
NOFOUND EXCEPTION ;
CURSOR Y3 IS
SELECT PAYMENT_DATE FROM UPAYMENT ;
BEGIN
OPEN Y3;
loop fetch Y3 into h;
IF Y3%NOTFOUND THEN RAISE NOTFOUND;
IF (:NEW.PAYMENT_DATE >= '01-JAN-22'and INSERTING)
THEN
:NEW.AMOUNT := :NEW.AMOUNT * 1.5;
ELSE
END LOOP;
END IF;
CLOSE Y3;
END IF;
exception when ERROR_
then DBMS_OUTPUT.PUT_LINE('ERROR');
END;

Quite a few errors.
trigger fires on insert; you don't have to check whether you're inserting (besides, you can't do that as you did)
don't compare dates to strings; use date literal or TO_DATE function with appropriate format mask
you can't modify :new values in an after trigger; must be before
you can't (actually, you shouldn't) end loop in the middle of IF
what do you need the loop for, anyway?
When fixed, trigger looks like this and kind of works:
SQL> create or replace trigger a
2 before insert on upayment
3 for each row
4 declare
5 error_ exception ;
6 h varchar2(20);
7 nofound exception ;
8 cursor y3 is
9 select payment_date from upayment ;
10 begin
11 open y3;
12 loop
13 fetch y3 into h;
14
15 if y3%notfound then
16 raise nofound;
17 else
18 if :new.payment_date >= date '2022-01-01' then
19 :new.amount := :new.amount * 1.5;
20 end if;
21 end if;
22 end loop;
23 close y3;
24
25 exception when nofound then
26 dbms_output.put_line('ERROR');
27 end;
28 /
Trigger created.
SQL> desc upayment
Name Null? Type
----------------------------------------- -------- ----------------------------
PAYMENT_DATE DATE
AMOUNT NUMBER
SQL> insert into upayment (payment_date, amount) values (sysdate, 100);
ERROR
1 row created.
SQL>
Though, I guess that you could simplify it (remove cursor, loop, user-defined exception, ... what not) to
SQL> create or replace trigger a
2 before insert on upayment
3 for each row
4 begin
5 if :new.payment_date >= date '2022-01-01' then
6 :new.amount := :new.amount * 1.5;
7 end if;
8 end;
9 /
Trigger created.
SQL> insert into upayment (payment_date, amount) values (sysdate, 500);
1 row created.
SQL> select * from upayment;
PAYMENT_DATE AMOUNT
------------------- ----------
19.01.2022 22:28:03 150
19.01.2022 22:32:57 750
SQL>

Related

Oracle plsql error PLS-00642: local collection types not allowed in SQL statements

I Am writing and pl/sql procedure and getting the error as
PLS-00642: local collection types not allowed in SQL statements and
PL/SQL: ORA-00947: not enough values
first i called a cursor and iterate the cursor and again fetching into a record there error is coming.
declare
type t1 is record (
msisdn varchar2(20),
imsi varchar2(14),
date_time date,
mml_cmd varchar2(50),
cmd_executed varchar2(2500),
myrank number);
type t2 is table of t1;
l_k t2;
type t3 is table of hlr_agent_logs%rowtype;
l_tab t3;
cursor c1 is select * from hlr_agent_logs where date_time>trunc(sysdate-2) and mml_cmd='ADD USER' and cmd_executed like '%Profile=3%' order by date_time;
begin
open c1;
loop
fetch c1 bulk collect into l_tab limit 500;
exit when l_tab.count=0;
for i in l_tab.first .. l_tab.last loop
begin
select msisdn, imsi, date_time , mml_cmd,cmd_executed,rank() over (partition by imsi order by date_time asc) as myrank into l_k from hlr_agent_logs
where substr(msisdn,3)=l_tab(i).msisdn and imsi=l_tab(i).imsi and date_time>=l_tab(i).date_time;
for k in l_k.first..l_k.last loop
dbms_output.put_line(l_k(k).msisdn);
end loop;
exception when no_data_found then
null;
end;
end loop;
close c1;
end loop;
end;
/
What you can and can't do with PLSQL collections directly from SQL varies from version to version, but it might be as simply as you not having the BULK COLLECT because you are fetching into a table
SQL> declare
2 type rec is record (
3 c1 int,
4 c2 int );
5
6 type mylist is table of rec;
7 n mylist;
8 begin
9 select 1,2 into n from dual;
10 end;
11 /
select 1,2 into n from dual;
*
ERROR at line 9:
ORA-06550: line 9, column 21:
PLS-00642: local collection types not allowed in SQL statements
ORA-06550: line 9, column 23:
PL/SQL: ORA-00947: not enough values
ORA-06550: line 9, column 5:
PL/SQL: SQL Statement ignored
SQL>
SQL> declare
2 type rec is record (
3 c1 int,
4 c2 int );
5
6 type mylist is table of rec;
7 n mylist;
8 begin
9 select 1,2 bulk collect into n from dual;
10 end;
11 /
PL/SQL procedure successfully completed.
As #Connor McDonnal wisely said, depending on the version, you can or cannot use PLSQL types on SQL, but having them declared as schema objects. As you did not say which version of Oracle are you using, let me show you an example with Oracle 19c
declare
type t1 is record (
msisdn varchar2(20),
imsi varchar2(14),
date_time date,
mml_cmd varchar2(50),
cmd_executed varchar2(2500),
myrank number);
type t2 is table of t1;
l_k t2;
type t3 is table of hlr_agent_logs%rowtype;
l_tab t3;
cursor c1 is select * from hlr_agent_logs where date_time>trunc(sysdate-2) and mml_cmd='ADD USER' and cmd_executed like '%Profile=3%' order by date_time;
begin
open c1;
loop
fetch c1 bulk collect into l_tab limit 500;
exit when l_tab.count=0;
for i in l_tab.first .. l_tab.last loop
begin
select msisdn, imsi, date_time , mml_cmd,cmd_executed,rank() over (partition by imsi order by date_time asc) as myrank bulk collect into l_k
from hlr_agent_logs
where substr(msisdn,3)=l_tab(i).msisdn and imsi=l_tab(i).imsi and date_time>=l_tab(i).date_time;
for k in l_k.first..l_k.last loop
dbms_output.put_line(l_k(k).msisdn);
end loop;
exception when no_data_found then
null;
end;
end loop;
close c1;
end loop;
end;
/
Output
SQL> l
1 declare
2 type t1 is record (
3 msisdn varchar2(20),
4 imsi varchar2(14),
5 date_time date,
6 mml_cmd varchar2(50),
7 cmd_executed varchar2(2500),
8 myrank number);
9 type t2 is table of t1;
10 l_k t2;
11 type t3 is table of hlr_agent_logs%rowtype;
12 l_tab t3;
13 cursor c1 is select * from hlr_agent_logs where date_time>trunc(sysdate-2) and mml_cmd='ADD USER' and cmd_executed like '%Profile=3%' order by date_time;
14 begin
15 open c1;
16 loop
17 fetch c1 bulk collect into l_tab limit 500;
18 exit when l_tab.count=0;
19 for i in l_tab.first .. l_tab.last loop
20 begin
21 select msisdn, imsi, date_time , mml_cmd,cmd_executed,rank() over (partition by imsi order by date_time asc) as myrank bulk collect into l_k
22 from hlr_agent_logs
23 where substr(msisdn,3)=l_tab(i).msisdn and imsi=l_tab(i).imsi and date_time>=l_tab(i).date_time;
24 for k in l_k.first..l_k.last loop
25 dbms_output.put_line(l_k(k).msisdn);
26 end loop;
27 exception when no_data_found then
28 null;
29 end;
30 end loop;
31 close c1;
32 end loop;
33* end;
SQL> /
PL/SQL procedure successfully completed.
SQL>

why I am getting error in this bellow code?

Tables:
CREATE TABLE bus_details
(
bus_name CHAR (15) PRIMARY KEY,
total_seats NUMBER (3),
reserved_seats NUMBER (3)
);
CREATE TABLE busreservation_status
(
bus_name CHAR (15) REFERENCES bus_details (bus_name),
seat_id NUMBER (3),
reserved CHAR (2) CHECK (reserved IN ('y', 'n')),
customer_name CHAR (15)
);
PL/SQL code:
DECLARE
bname CHAR (15);
tot NUMBER (3);
resv NUMBER (3);
total_seats NUMBER (3);
CURSOR cur IS SELECT * FROM bus_details;
BEGIN
INSERT INTO bus_details
VALUES ('&bus_name', total_seats, 0);
OPEN cur;
LOOP
FETCH cur INTO bname, tot, resv;
IF cur%FOUND
THEN
FOR i IN 1 .. tot
LOOP
INSERT INTO busreservation_status
VALUES (bname,
i,
'n',
NULL);
END LOOP;
ELSE
EXIT;
END IF;
END LOOP;
CLOSE cur;
END;
/
Error:
ORA-06502: PL/SQL: numeric or value error
PL/SQL isn't supposed to be interactive with users. If you want to pass something to it, use a procedure with appropriate parameter(s).
If you rewrite code so that it looks like this
note cursor FOR loop instead of explicitly declared cursor which requires opening, declaring cursor variables, fetching, exiting the loop, closing the cursor
setting all required values for bus_details
don't use CHAR datatype unless it makes sense. For e.g. bus name it doesn't, as that datatype right-pads value with spaces up to max column length
Then it works:
SQL> DECLARE
2 l_bus_name VARCHAR2 (15) := 'BMW';
3 l_total_seats NUMBER := 20;
4 l_reserved_seats NUMBER := 5;
5 BEGIN
6 INSERT INTO bus_details (bus_name, total_seats, reserved_seats)
7 VALUES (l_bus_name, l_total_seats, l_reserved_seats);
8
9 FOR cur_r
10 IN (SELECT bus_name, total_seats, reserved_seats FROM bus_details)
11 LOOP
12 FOR i IN 1 .. cur_r.total_seats
13 LOOP
14 INSERT INTO busreservation_status
15 VALUES (cur_r.bus_name,
16 i,
17 'n',
18 NULL);
19 END LOOP;
20 END LOOP;
21 END;
22 /
PL/SQL procedure successfully completed.
Result is:
SQL> select * From bus_details;
BUS_NAME TOTAL_SEATS RESERVED_SEATS
--------------- ----------- --------------
BMW 20 5
SQL> SELECT * FROM busreservation_status;
BUS_NAME SEAT_ID RE CUSTOMER_NAME
--------------- ---------- -- ---------------
BMW 1 n
BMW 2 n
BMW 3 n
BMW 4 n
BMW 5 n
<snip>
BMW 19 n
BMW 20 n
20 rows selected.
SQL>
you have to set some value to the variable total_seats number(3); or prompt input value for total_seats when inserting operation in process:
for example:
Declare
bname Char(15);
tot Number(3);
resv Number(3);
total_seats Number(3) := 15;
Cursor cur Is
Select * From bus_details;
Begin
Insert Into bus_details Values ('&bus_name', total_seats, 0);
Open cur;
Loop
Fetch cur
Into bname, tot, resv;
If cur%Found Then
For i In 1 .. tot Loop
Insert Into busreservation_status Values (bname, i, 'n', Null);
End Loop;
Else
Exit;
End If;
End Loop;
Close cur;
End;
/
OR
Declare
bname Char(15);
tot Number(3);
resv Number(3);
total_seats Number(3);
Cursor cur Is
Select * From bus_details;
Begin
Insert Into bus_details Values ('&bus_name', '&total_seats', 0);
Open cur;
Loop
Fetch cur
Into bname, tot, resv;
If cur%Found Then
For i In 1 .. tot Loop
Insert Into busreservation_status Values (bname, i, 'n', Null);
End Loop;
Else
Exit;
End If;
End Loop;
Close cur;
End;
/
Yes you would need to insert bus_details first, the FK on busreservation_status to bus_details requires it. Further there are additional suggested changed.
Drop column reserved_seats from bus_details. This column is fully
derivable from busreservation_status and typically maintaining a
running count is just not worth the effort. But having it and not
maintaining leads to data errors. For Example: you can have more
seats reserved then the bus has seats.
Drop the column reserved from busreservation_status. This is
derivable from customer_name; if customer_name is not null the seat
is reserved. But assuming you "must keep it" then define is a
virtual column bases on customer_name. This would keep the column in
sync with there being a customer for the seat.
Change char columns to varchar2, and I would change number to
integer.
Create a procedure for setting up a bus (IMO better). The procedure
can be parameterized, not an attempt at user interaction - which
plsql can not do anyway. But whether you create a procedure or keep an anonymous block, there is no need for a loop; a single insert is all that is needed.
With the above in place we arrive at:
create table bus_details
(
bus_name varchar2 (15) primary key
, total_seats number (3)
);
create table busreservation_status
(
bus_name varchar2 (15) references bus_details (bus_name)
, seat_id number (3)
, customer_name varchar2 (15)
, reserved varchar2 (1) generated always as
( case when customer_name is null then 'n' else 'y' end) virtual
, constraint busreservation_status_pk
primary key (bus_name,seat_id)
);
create or replace
procedure define_bus(bus_name_in bus_details.bus_name%type
,seats_in bus_details.total_seats%type
)
is
begin
insert into bus_details(bus_name, total_seats)
values (bus_name_in, seats_in);
insert into busreservation_status(bus_name, seat_id)
select bus_name_in, level
from dual connect by level <= seats_in;
end ;
For quick look at the bus states at summary and detail level you can create views. The demo also includes a couple.

Procedure error - PLS-00103 Encountered the symbol ">"

I am trying to learn PLSQL and I have a problem creating a procedure.
The task I am solving is: Create a procedure to check commissions. Commissions higher than 0.35 can only be entered for employees with more than 15 years of experience. If the commission will be higher or practice will be lower, then an error will be printed. Take advantage of exceptions (Exception and Raise) to define an error message.
I wrote this, but there is an error:
PLS-00103 Encountered the symbol ">" when expecting one of following::= . ( # % ;
create or replace PROCEDURE PROVIZIA(num in number) IS
employee_id number;
com_pct employees.commission_pct%type;
begin
select commission_pct into com_pct from employees where employee_id = num;
if PRAX(employee_id) > 15 then
com_pct > 0.35;
else PRAX(employee_id) < 15 then
com_pct < 0.35;
end if;
exception when com_pct > 0.35 and PRAX(employee_id) < 15 then
dbms_output.put_line('error');
raise;
end PROVIZIA;
Can you please show me where i am making a mistake?
Thank you.
Suppose this is a test case (table and prax function which returns some number; I don't know which and why, so I made it so that it returns an "invalid" value for employee 1):
SQL> create table employees as
2 select 1 employee_id, 0.5 commission_pct from dual union all
3 select 2, 0.2 from dual;
Table created.
SQL> create or replace function prax(par_empid in number) return number is
2 begin
3 return case when par_empid = 1 then 10
4 else 50
5 end;
6 end prax;
7 /
Function created.
SQL> select employee_id, commission_pct, prax(employee_id) prax_result
2 from employees;
EMPLOYEE_ID COMMISSION_PCT PRAX_RESULT
----------- -------------- -----------
1 ,5 10 --> this combination is invalid
2 ,2 50 --> this is OK
SQL>
Procedure which raises an error if values are "wrong"; doesn't do anything otherwise (because you didn't say what to do in that case):
SQL> create or replace procedure provizia(num in number) is
2 com_pct employees.commission_pct%type;
3 l_err exception;
4 begin
5 select commission_pct
6 into com_pct
7 from employees
8 where employee_id = num;
9
10 if com_pct > 0.35 and prax(num) < 15 then
11 raise l_err;
12 end if;
13
14 exception
15 when l_err then
16 raise_application_error(-20000, 'Error');
17 end provizia;
18 /
Procedure created.
SQL>
Let's test it:
SQL> exec provizia(num => 1);
BEGIN provizia(num => 1); END;
*
ERROR at line 1:
ORA-20000: Error
ORA-06512: at "SYS.PROVIZIA", line 16
ORA-06512: at line 1
SQL> exec provizia(num => 2);
PL/SQL procedure successfully completed.
SQL>
Now that you have a working example, feel free to improve it.
com_ptc > 0.35
You can not write like this.Its return you true or false.
Look at the given pix.
If you use TOAD.exe then you will notify the runtime errors.
Look at the marked area.
Let's try this
CREATE OR REPLACE PROCEDURE PROVIZIA (num IN NUMBER)
IS
employee_id NUMBER;
com_pct employees.commission_pct%TYPE;
BEGIN
SELECT commission_pct
INTO com_pct
FROM employees
WHERE employee_id = num;
IF com_pct > 0.35 AND PRAX (employee_id) < 15
THEN
DBMS_OUTPUT.put_line ('error');
ELSE
DBMS_OUTPUT.put_line ('OK');
END IF;
END PROVIZIA;

plsql what is wrong with this code error 'INTO list is of wrong type'

Can someone please help me? Why do I get this error "INTO list is of wrong type"?
DECLARE
TYPE v_dept_table IS TABLE OF DEPARTMENTS.DEPARTMENT_NAME%TYPE INDEX BY PLS_INTEGER;
v_record_dept_table v_dept_table;
v_loop_count NUMBER := 10;
v_dept_no NUMBER := 1;
BEGIN
FOR v_dept_no IN 1..v_loop_count LOOP
SELECT DEPARTMENTS.DEPARTMENT_NAME
INTO v_record_dept_table
FROM DEPARTMENTS
WHERE DEPARTMENT_ID = v_dept_no;
v_dept_no := v_dept_no + 1;
INSERT
INTO v_dept_table
VALUES v_record_dept_table;
END LOOP;
FOR indx IN NVL (v_dept_table.FIRST, 0) .. NVL (v_dept_table.LAST, -1)
LOOP
DBMS_OUTPUT.PUT_LINE(v_dept_table(indx));
END LOOP;
END;
ORA-06550: line 16, column 14:
PLS-00597: expression 'V_RECORD_DEPT_TABLE' in the INTO list is of wrong type
Why is it a wrong type? I'm using the hr schema from Oracle
Not exactly like that; you've done several things wrong. I tried to fix your code (with as little modifications as possible); have a look, read comments I wrote, compare it to your code. Side note: I used Scott's DEPT table as I don't have your DEPARTMENTS.
SQL> set serveroutput on
SQL> DECLARE
2 TYPE v_dept_table IS TABLE OF dept.dname%TYPE
3 INDEX BY PLS_INTEGER;
4
5 v_record_dept_table v_dept_table;
6
7 v_loop_count NUMBER := 10;
8 v_dept_no NUMBER := 1;
9 BEGIN
10 FOR v_dept_no IN 1 .. v_loop_count
11 LOOP
12 BEGIN
13 SELECT dname
14 INTO v_record_dept_table (v_dept_no) --> you're missing "(v_dept_no)"
15 FROM dept
16 WHERE deptno = v_dept_no;
17 -- Don't manually increment FOR loop variable; Oracle does it itself
18 -- v_dept_no := v_dept_no + 1;
19
20 -- You can't insert into "type"; besides, you've already inserted into V_RECORD_DEPT_TABLE.
21 -- INSERT INTO v_dept_table VALUES v_record_dept_table;
22 EXCEPTION
23 WHEN NO_DATA_FOUND
24 THEN
25 NULL;
26 END;
27 END LOOP;
28
29 -- loop through V_RECORD_DEPT_TABLE (collection), not V_DEPT_TABLE (type). No need for NVL.
30 FOR indx IN NVL (v_record_dept_table.FIRST, 0) ..
31 NVL (v_record_dept_table.LAST, -1)
32 LOOP
33 DBMS_OUTPUT.PUT_LINE (v_record_dept_table (indx));
34 END LOOP;
35 END;
36 /
ACCOUNTING
PL/SQL procedure successfully completed.
SQL>
Alternatively, see whether this helps. I used built-in type (sys.odcivarchar2list) and BULK COLLECT INTO (performs better).
SQL> DECLARE
2 v_record_dept_table SYS.odcivarchar2list;
3 BEGIN
4 SELECT dname
5 BULK COLLECT INTO v_record_dept_table
6 FROM dept;
7
8 FOR indx IN v_record_dept_table.FIRST .. v_record_dept_table.LAST
9 LOOP
10 DBMS_OUTPUT.PUT_LINE (v_record_dept_table (indx));
11 END LOOP;
12 END;
13 /
ACCOUNTING
RESEARCH
SALES
OPERATIONS
PL/SQL procedure successfully completed.
SQL>

oracle delete data from table with rownum

I have a procedure that deletes the data from table1. Five instances of the procedure running the same time and all ran without any error/exception.
But still, there are many records in the table1 where EndTime <= v_purgedate. Please help.
declare
rowcount1 NUMBER;
begin
LOOP
delete table1 eh
where eh.EndTime <= v_purgedate
and rownum <= 30000 ;
rowcount1 := rowcount1 + sql%rowcount;
commit;
exit when rowcount1=0;
rowcount1=0;
END LOOP;
end;
/
You are trying to do what is called "do it yourself parallelism", as opposed to the parallel processing that Oracle can do by itself if you ask nicely.
There is a package called DBMS_PARALLEL_EXECUTE that does this for you. You split the data into chunks (based on ROWIDs or numbers), then call the RUN_TASK procedure to process each chunk, either serially or in parallel. There is one commit per chunk.
Here is a demonstration that deletes 30,000 rows per commit. First, test data:
SQL> create table table1(endtime) as
2 select trunc(sysdate) - level/24 from dual
3 connect by level <= 240000;
Table TABLE1 created.
SQL> insert into table1 select * from table1;
240,000 rows inserted.
SQL> insert into table1 select * from table1;
480,000 rows inserted.
SQL> insert into table1 select * from table1;
960,000 rows inserted.
SQL> select count(*) from table1;
COUNT(*)
----------
1920000
Now, here is the code:
SQL> declare
2 l_task_name varchar2(128) := 'Delete_TABLE1';
3 l_sql_chunk clob := q'§
4 select date '2100-01-01' - min(endtime) start_id,
5 date '2100-01-01' - max(endtime) end_id,
6 chunk
7 from (
8 select endtime,
9 ceil(row_number() over(order by endtime) / 30000) chunk
10 from table1 where endtime < sysdate - 8000
11 )
12 group by chunk
13 §';
14 l_sql_run clob := q'§
15 delete from table1
16 where endtime between
17 date '2100-01-01' - :start_id and
18 date '2100-01-01' - :end_id
19 §';
20 l_boolean boolean := false;
21 task_not_found EXCEPTION;
22 PRAGMA EXCEPTION_INIT(task_not_found, -29498);
23 begin
24 begin
25 DBMS_PARALLEL_EXECUTE.DROP_TASK (l_task_name);
26 exception when task_not_found then null;
27 end;
28 DBMS_PARALLEL_EXECUTE.CREATE_TASK (l_task_name);
29 DBMS_PARALLEL_EXECUTE.CREATE_CHUNKS_BY_SQL (
30 task_name => l_task_name,
31 sql_stmt => l_sql_chunk,
32 by_rowid => l_boolean
33 );
34 DBMS_PARALLEL_EXECUTE.RUN_TASK (
35 task_name => l_task_name,
36 sql_stmt => l_sql_run,
37 language_flag => 1,
38 parallel_level => 0 -- 0 for serial, 2+ for parallel
39 );
40 end;
41 /
you have an endless Loop, because rowcount1 will never be 0 when your table contains data that will be deleted.
i think what you what is
declare
rowcount1 NUMBER;
begin
LOOP
delete table1 eh
where eh.EndTime <= v_purgedate -- you should also initialize a variable
and rownum <= 30000 ;
--rowcount1 := rowcount1 + sql%rowcount;
commit;
exit when sql%rowcount = 0;
rowcount1=0;
END LOOP;
end;
/
When you declare the variable rowcount1, you do not assign any number to it, so its value is NULL. Afterwards, when you add a number to NULL the result is always NULL. This is surely not what you want. To illustrate:
SQL> declare
2 rowcount1 NUMBER;
3 begin
4 dbms_output.put_line('<'||rowcount1||'>');
5 rowcount1 := rowcount1 + 1;
6 dbms_output.put_line('<'||rowcount1||'>');
7 end;
8 /
<>
<>
PL/SQL procedure successfully completed.
It seems your code will go in an endless loop. You say that is not the case, so clearly you are not showing us any real code.
Anyway, this is not a good way to do what you want. I'll post another answer saying why.
Regards, Stew Ashton
It's a easy code for delete data in a table .
Try it.
declare
cursor c is
select * from table1 where rownum<=30000;
begin
for i in c loop
delete from table1 where EndTime <= v_purgedate;
end loop;
commit;
end;

Resources