下面是确定表是否存在然后删除/创建表的 PL/SQL 脚本。如果它不存在,无论如何都要创建表。因此,当我运行脚本时,我收到以下信息:
ORA-00904: "E": 无效标识符
我认为语法是准确的,双引号的“E”是正确的,但显然不是。请指教。
谢谢。
DECLARE
l_cnt NUMBER;
BEGIN
SELECT COUNT(*)
INTO l_cnt
FROM dba_tables
WHERE owner = 'ABCD'
AND table_name = 'SEC_REC_TEMP';
IF( l_cnt > 0 )
THEN
EXECUTE IMMEDIATE 'DROP TABLE sec_rec_temp';
EXECUTE IMMEDIATE 'CREATE TABLE sec_rec_temp
AS
SELECT is.inv_num
FROM abcd.inv_summ is
,abcd.bill_fee bf
WHERE is.inv_num = bf.inv_num
AND trim(bf.fee_type) = "E"
GROUP BY is.inv_num';
ELSE
EXECUTE IMMEDIATE 'CREATE TABLE sec_rec_temp
AS
SELECT is.inv_num
FROM abcd.inv_summ is
,abcd.bill_fee bf
WHERE is.inv_num = bf.inv_num
AND trim(bf.fee_type) = "E"
GROUP BY is.inv_num';
END IF;
END;
/