我有一个安装脚本,我试图根据远程数据库中的表创建多个视图。该脚本将在多个数据库上执行,每个数据库都有自己的远程数据库。我打算在安装过程中提示远程数据库链接作为输入参数,而不是创建脚本的多个版本。但是,当我执行安装脚本时,第一个视图将失败并显示ORA-02019,而其余视图已成功创建。
样本测试版本:
install.sql
Set serveroutput on
SET VERIFY OFF
Alter Session Set current_schema = TEST;
SET VERIFY ON
DEFINE DB_LINK = &&db_link
PROMP Install started ...
@./SCRIPTS/views.sql
PROMP Install ended
quit
@。/ SCRIPTS / views.sql
--View1
Create or replace View tmp_cards as Select nvl((select count(*) from auths@&db_link where cardid = t.id),0) cnt_auths,t.* From Cards@&db_link t ;
--View2
Create or replace View tmp_Auth as Select * From auths@&db_link;
安装日志
IMPLUSER@db01 SQL>@install.sql
Session altered.
Enter value for db_link: db02
Install started ...
old 1: Create or replace View tmp_cards as Select nvl((select count(*) from auths@&db_link where cardid = t.id),0) cnt_auths,t.* From Cards@&db_link t
new 1: Create or replace View tmp_cards as Select nvl((select count(*) from auths@db02 where cardid = t.id),0) cnt_auths,t.* From Cards@db02 t
Create or replace View tmp_cards as Select nvl((select count(*) from auths@db02 where cardid = t.id),0) cnt_auths,t.* From Cards@db02 t
*
ERROR at line 1:
ORA-02019: connection description for remote database not found
old 1: Create or replace View tmp_Auth as Select * From auths@&db_link
new 1: Create or replace View tmp_Auth as Select * From auths@db02
View created.
Install ended
如果我直接通过PL / SQL中的命令窗口创建视图,则第一个视图成功创建
SQL> Create or replace View tmp_cards as Select nvl((select count(*) from auths@db02 where I002_NUMBER = t.cardnumber),0) cnt_auths,t.* From Cards@db02 t;
View created
SQL>
我错过了什么?