how to truncate table in a pl/sql block
972227Apr 23 2013 — edited Apr 23 2013Hello guys, i am trying to truncate a table that consists of data using a pl/sql block, so if the table consists of even a single row then the truncate should execute. for that i wrote the following code
declare
num number;
begin
select count(*) into num from table_name;
if num > 0 then
truncate table table_name;
end if;
end;
Now when i am executing this pl/sql block, i am getting the following error.
PLS-00103: Encountered the symbol "TABLE" when expecting one of the following:
when I execute the truncate command without the pl/sql, it executes fine.
Can some one please tell where I am going wrong.
Thank You
Edited by: 969224 on Apr 23, 2013 8:08 AM