日期:2014-05-16  浏览次数:20779 次

怎麼建立關聯兩個scheam中table的儲存過程?
在scheam1下執行下面動作 : 

CREATE OR REPLACE PROCEDURE scheam1.test AS P_ID VARCHAR2(50);

BEGIN
SELECT
scheam2.table2.name INTO NAME 
FROM
scheam1.table1 table1 
INNER JOIN scheam2.table2 table2
ON table1.id=table2.id

dbms_output.put_line(P_ID);
END;

編譯后,會提示錯誤信息 : PL/SQL: ORA-00942: table or view does not exist
感覺應該是找不到scheam2中的table吧

這樣的情況要如何處理呢?

------解决方案--------------------
grant select any table to scheam1

另外oracle里的方案叫schema
------解决方案--------------------
0. 在schema2下, grant select any table to schema1.
1. 在schema1下,建一个table2的synonym。
2. 在procedure中去掉table2前面的schema2前缀。