Skip to Main Content

Oracle Database Discussions

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 truncate table in a pl/sql block

972227Apr 23 2013 — edited Apr 23 2013
Hello 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
This post has been answered by sb92075 on Apr 23 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2013
Added on Apr 23 2013
6 comments
4,545 views