如果没有进入tables_found过程将运行,但我需要检查我的数据库中是否存在此表。
CREATE OR replace PROCEDURE dropdb(tables_found out number) IS
BEGIN
execute immediate 'SELECT COUNT(*) into tables_found FROM user_tables where table_name=''USERS''';
if (tables_found = 1) then
execute immediate ' drop table users';
END IF;
END dropdb;
错误日志:
ora-00905缺少关键字
答案 0 :(得分:0)
一定是这个
Execute immediate 'SELECT COUNT(*) FROM user_tables where table_name=''USERS''' into tables_found;
甚至更好:
Execute immediate 'SELECT COUNT(*) FROM user_tables where table_name=:name' into tables_found using 'USERS';
答案 1 :(得分:0)
尝试:
execute immediate 'SELECT COUNT(*) into :x FROM user_tables
where table_name=''USERS'''
USING OUT tables_found ;
如果以上操作不起作用,请尝试以下操作:
execute immediate 'DECLARE x NUMBER; BEGIN SELECT COUNT(*) into x
FROM user_tables
where table_name=''USERS'';
:tables := x END'
USING OUT tables_found ;