實驗環境:
庫一:12c prodcdb1
庫二:11g rocky
1. 實驗準備:在12c版本的pdb庫prodcdb1中建立乙個普通使用者test
[oracle@host01 ~]$ . oraenv
oracle_sid = [prodcdb1] ?
prodcdb
[oracle@host01 ~]$ sqlplus / as sysdba
sql*plus: release 12.1.0.2.0 production on thu jul 12 18:48:48 2018
connected to:
oracle database 12c enterprise edition release 12.1.0.2.0 - 64bit production
sys@ prodcdb>conn sys/oracle@prodcdb1 as sysdba
sys@ prodcdb1>create user test identified by test ;
sys@ prodcdb1>alter user test account unlock;
sys@ prodcdb1>grant connect,resource to test;
sys@ prodcdb1>conn test/test@prodcdb1
2.在12c版本的pdb庫prodcdb1上,使用者test建立函式add_num
create or replace function add_num(a int, b int) return int is
v_c int;
begin
select a + b into v_c from dual;
return v_c;
end;
3.在11g版本庫rocky上面建立dblink
create database link prodcdb1
connect to test identified by test
using '(description =
(address_list =
(address = (protocol = tcp)(host = host01.example.com)(port = 1521))
)
(connect_data =
(server = dedicated)
(service_name = prodcdb1.example.com)
)
)' ;
4.在庫rocky上面呼叫庫prodcdb1使用者test下的函式add_num
儲存過程呼叫:
declare
a int:=3;
b int:=4;
v_sql varchar2(100):=null;
begin
v_sql := 'select add_num@prodcdb1(:1,:2) from dual ' ;
execute immediate v_sql using a,b;
end;
直接呼叫:
connected to oracle database 11g enterprise edition release 11.2.0.1.0
connected as sys@rocky as sysdba
sql> select add_num@prodcdb1(1,2) from dual;
add_num@prodcdb1(1,2)
---------------------
3
記錄 Oracle 遠端呼叫 HTTP 介面
4.可能會使用到 遇到的問題 提供參考 restcontroller abouttriggercontroller public class abouttriggercontroller 儲存過程,需要在sql視窗中執行 使用超級管理員使用者執行 根據自己的需求對裡面的內容進行修改。principa...
呼叫遠端資料庫的函式
這樣子寫 select from openquery 192.168.0.1 select from db dbo.user func list 沒有問題。這樣子寫 select a.b.from a,openquery 192.168.0.1 select from db dbo.user fun...
oracle函式的建立和呼叫
函式的建立create or replace function addfunction x in number,y out number return number is results number 0 begin results x 1 dbms output.put line results ...