Oracle DB link 转化为变量
Oracle DB link into variable
我有以下程序,我想根据数据库 link 使我的 select 查询动态化。所以我将数据库 link 放入变量 IN_DB_CONNECTION_NAME
并在我的 select 查询中提供,但我收到错误消息:
PL/SQL: ORA-00942: table or view does not exist.
我正在使用正确的 sql 查询从 db_connection table 获取数据库 link。
这是我的 DB_CONNECTION
table:
PROCEDURE "EXT_10004_SELF_SIGWF_CVB"(IN_KPI_DEF_ID IN NUMBER DEFAULT 0) AS
IN_EVENT_ID NUMBER;
IN_DB_CONNECTION_NAME VARCHAR2(100);
BEGIN
Select EVENT_ID INTO IN_EVENT_ID FROM RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION where KPI_DEF_ID = IN_KPI_DEF_ID;
Select DB.DB_LINK INTO IN_DB_CONNECTION_NAME FROM KPI_DEFINITION KD
join DB_CONNECTION DB ON KD.DB_CONNECTION_ID = DB.DB_CONNECTION_ID
AND KD.KPI_DEF_ID = IN_KPI_DEF_ID;
Insert into TEMP_WF_WORKFLOW_EXTRACTION(ID,NAME,SUBSCRIPTION_ID)
Select DISTINCT(WF.ID),WF.NAME,WF.SUBSCRIPTION_ID
from WF_WORKFLOW@IN_DB_CONNECTION_NAME WF where
WF.STATUS_ID = 0 and WF.NAME IN ('CVB pack subscribe')
END EXT_10004_SELF_SIGWF_CVB;
类似
PROCEDURE "EXT_10004_SELF_SIGWF_CVB"(IN_KPI_DEF_ID IN NUMBER DEFAULT 0) AS
IN_EVENT_ID NUMBER;
IN_DB_CONNECTION_NAME VARCHAR2(100);
l_sql varchar2(500);
BEGIN
Select EVENT_ID INTO IN_EVENT_ID FROM RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION where KPI_DEF_ID = IN_KPI_DEF_ID;
Select DB.DB_LINK INTO IN_DB_CONNECTION_NAME FROM KPI_DEFINITION KD
join DB_CONNECTION DB ON KD.DB_CONNECTION_ID = DB.DB_CONNECTION_ID
AND KD.KPI_DEF_ID = IN_KPI_DEF_ID;
l_sql:= 'insert into...from WF_WORKFLOW@'||IN_DB_CONNECTION_NAME||' WF...';
/* Insert into TEMP_WF_WORKFLOW_EXTRACTION(ID,NAME,SUBSCRIPTION_ID)
Select DISTINCT(WF.ID),WF.NAME,WF.SUBSCRIPTION_ID
from WF_WORKFLOW@IN_DB_CONNECTION_NAME WF where
WF.STATUS_ID = 0 and WF.NAME IN ('CVB pack subscribe') */
execute immediate l_sql;
END EXT_10004_SELF_SIGWF_CVB;
我有以下程序,我想根据数据库 link 使我的 select 查询动态化。所以我将数据库 link 放入变量 IN_DB_CONNECTION_NAME
并在我的 select 查询中提供,但我收到错误消息:
PL/SQL: ORA-00942: table or view does not exist.
我正在使用正确的 sql 查询从 db_connection table 获取数据库 link。
这是我的 DB_CONNECTION
table:
PROCEDURE "EXT_10004_SELF_SIGWF_CVB"(IN_KPI_DEF_ID IN NUMBER DEFAULT 0) AS
IN_EVENT_ID NUMBER;
IN_DB_CONNECTION_NAME VARCHAR2(100);
BEGIN
Select EVENT_ID INTO IN_EVENT_ID FROM RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION where KPI_DEF_ID = IN_KPI_DEF_ID;
Select DB.DB_LINK INTO IN_DB_CONNECTION_NAME FROM KPI_DEFINITION KD
join DB_CONNECTION DB ON KD.DB_CONNECTION_ID = DB.DB_CONNECTION_ID
AND KD.KPI_DEF_ID = IN_KPI_DEF_ID;
Insert into TEMP_WF_WORKFLOW_EXTRACTION(ID,NAME,SUBSCRIPTION_ID)
Select DISTINCT(WF.ID),WF.NAME,WF.SUBSCRIPTION_ID
from WF_WORKFLOW@IN_DB_CONNECTION_NAME WF where
WF.STATUS_ID = 0 and WF.NAME IN ('CVB pack subscribe')
END EXT_10004_SELF_SIGWF_CVB;
类似
PROCEDURE "EXT_10004_SELF_SIGWF_CVB"(IN_KPI_DEF_ID IN NUMBER DEFAULT 0) AS
IN_EVENT_ID NUMBER;
IN_DB_CONNECTION_NAME VARCHAR2(100);
l_sql varchar2(500);
BEGIN
Select EVENT_ID INTO IN_EVENT_ID FROM RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION where KPI_DEF_ID = IN_KPI_DEF_ID;
Select DB.DB_LINK INTO IN_DB_CONNECTION_NAME FROM KPI_DEFINITION KD
join DB_CONNECTION DB ON KD.DB_CONNECTION_ID = DB.DB_CONNECTION_ID
AND KD.KPI_DEF_ID = IN_KPI_DEF_ID;
l_sql:= 'insert into...from WF_WORKFLOW@'||IN_DB_CONNECTION_NAME||' WF...';
/* Insert into TEMP_WF_WORKFLOW_EXTRACTION(ID,NAME,SUBSCRIPTION_ID)
Select DISTINCT(WF.ID),WF.NAME,WF.SUBSCRIPTION_ID
from WF_WORKFLOW@IN_DB_CONNECTION_NAME WF where
WF.STATUS_ID = 0 and WF.NAME IN ('CVB pack subscribe') */
execute immediate l_sql;
END EXT_10004_SELF_SIGWF_CVB;