帮忙看一条SQL,错在哪里?

wanjiashu 2004-12-22 03:24:21
set serveroutput on
declare li_count int;
ls_user varchar2(50);
begin
select user into ls_user from dual;
dbms_output.put_line (ls_user);
select count(*) into li_count from dba_tables where OWNER = ls_user and table_name = 'ABC';
dbms_output.put_line (li_count);
if li_count > 0 then
DROP TABLE ABC ;
end if;
end;

报告说 drop table abc ;的地方出错,谢谢!
...全文
89 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
delphi_dcs 2004-12-22
  • 打赏
  • 举报
回复
虽然安全,但还是没MS的东东方便
doulikeme 2004-12-22
  • 打赏
  • 举报
回复
这样用吧,PLSQL不支持直接用drop

EXECUTE IMMEDIATE 'DROP TABLE ABC';
ORARichard 2004-12-22
  • 打赏
  • 举报
回复
set serveroutput on
declare li_count int;
ls_user varchar2(50);
begin
select user into ls_user from dual;
dbms_output.put_line (ls_user);
select count(*) into li_count from dba_tables where OWNER = ls_user and table_name = 'ABC';
dbms_output.put_line (li_count);
if li_count > 0 then
execute immediate 'DROP TABLE ABC' ;
end if;
end;
doulikeme 2004-12-22
  • 打赏
  • 举报
回复
编译时候的错误还是运行时候的错误??

错误号??

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧