亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標題: 求助:光標中如何使用同義詞 [打印本頁]

作者: gz_xuhaoz    時間: 2007-09-09 17:06
標題: 求助:光標中如何使用同義詞
在存儲過程中寫的光標,有一表和一同義詞關(guān)聯(lián),創(chuàng)建時提示表或視圖不存在,
         把查詢語句放在SQLPLUS中可以執(zhí)行。
         
         請教大俠們有何辦法修正。

[ 本帖最后由 gz_xuhaoz 于 2007-9-9 17:07 編輯 ]
作者: numenhuang    時間: 2007-09-09 21:27
創(chuàng)建存儲過程的用戶和同義詞,表的用戶是否是同一用戶
作者: gz_xuhaoz    時間: 2007-09-10 09:43
標題: 回復(fù) #2 numenhuang 的帖子
過程與同義詞為同一用戶, 同義詞的源表在另一用戶。

在當前用戶中可以讀取同義詞源表的用戶的表。
作者: numenhuang    時間: 2007-09-10 10:34
原帖由 gz_xuhaoz 于 2007-9-10 09:43 發(fā)表
過程與同義詞為同一用戶, 同義詞的源表在另一用戶。

在當前用戶中可以讀取同義詞源表的用戶的表。


cursor中和同義詞關(guān)聯(lián)表的用戶是誰
作者: gz_xuhaoz    時間: 2007-09-10 10:48
原帖由 numenhuang 于 2007-9-10 10:34 發(fā)表


cursor中和同義詞關(guān)聯(lián)表的用戶是誰



同義詞關(guān)聯(lián)表的用戶:  是另一個用戶。
其它的都是在同一用戶中。

  如:
    在用戶A中。
 

   create  procedure .....

          cursor c1   is select  ......   from  XXXX  ,YYYY
           where .....
           
           
           其中: XXXXX為表, 
              YYYY為同義詞!∷年P(guān)聯(lián)源表為B用戶。
           可以在sqlplus 下進行查詢:select * from YYYYY;

[ 本帖最后由 gz_xuhaoz 于 2007-9-10 10:52 編輯 ]
作者: numenhuang    時間: 2007-09-10 10:57
有沒有權(quán)限訪問這個關(guān)聯(lián)表,
不是同義詞的基表。
作者: gz_xuhaoz    時間: 2007-09-10 11:13
原帖由 numenhuang 于 2007-9-10 10:57 發(fā)表
有沒有權(quán)限訪問這個關(guān)聯(lián)表,
不是同義詞的基表。


哪個關(guān)聯(lián)表?
作者: numenhuang    時間: 2007-09-10 11:19
把cursor定義貼上來
作者: gz_xuhaoz    時間: 2007-09-10 11:25
標題: 回復(fù) #8 numenhuang 的帖子
cursor c2 is select  b.Imsino imsino,c.nogroupid  nogroupid ,b.hostflag hostflag
      from  XXXX b ,YYYY c
         where  b.Usestate=0  AND b.Imsisectid=c.imsisectid
         and b.iccid=v_iccid;
         
         YYYY是個同義詞。
         XXXX是個表
作者: numenhuang    時間: 2007-09-10 11:27
xxxx,yyyy前分別帶上schema名稱,再測試

[ 本帖最后由 numenhuang 于 2007-9-10 12:38 編輯 ]
作者: gz_xuhaoz    時間: 2007-09-10 14:28
原帖由 numenhuang 于 2007-9-10 11:27 發(fā)表
xxxx,yyyy前分別帶上schema名稱,再測試


  加上了也不行。
作者: numenhuang    時間: 2007-09-10 15:11
create or replace procedure test
as
cursor cc is select * from YYYY;
begin
null;
end;
/

能否創(chuàng)建
作者: gz_xuhaoz    時間: 2007-09-10 15:47
原帖由 numenhuang 于 2007-9-10 15:11 發(fā)表
create or replace procedure test
as
cursor cc is select * from YYYY;
begin
null;
end;
/

能否創(chuàng)建



不能創(chuàng)建

Warning: Procedure created with compilation errors.

SQL> show errors
Errors for PROCEDURE TEST:

LINE/COL ERROR
-------- -----------------------------------------------------------------
3/14     PL/SQL: SQL Statement ignored
3/28     PL/SQL: ORA-00942: table or view does not exist



SQL> select count(*) from YYYY;

  COUNT(*)
----------
     10423
作者: numenhuang    時間: 2007-09-10 15:51
sqlplus system
sql>select * from dba_synonyms where synonym_name='YYYY'
貼出來看看

create or replace procedure test
as
cursor cc is select * from 同義詞基表用戶.同義詞基表;
begin
null;
end;
作者: gz_xuhaoz    時間: 2007-09-10 16:04
原帖由 numenhuang 于 2007-9-10 15:51 發(fā)表
sqlplus system
sql>select * from dba_synonyms where synonym_name='YYYY'
貼出來看看

create or replace procedure test
as
cursor cc is select * from 同義詞基表用戶.同義詞基表;
begin
null;
end;



SQL> SHOW USER
USER is "FSZW_LSGJ"

select * from dba_synonyms where synonym_name='IM_PR_NOSECT'

OWNER                          TABLE_OWNER
------------------------------ ------------------------------
TABLE_NAME
------------------------------
FSZW_LSGJ                      COMMON_LSGJ
IM_PR_NOSECT


SQL>
SQL> create or replace procedure test
  2  as
  3  cursor cc is select * from COMMON_LSGJ.IM_PR_NOSECT;
  4  begin
  5  null;
  6  end;
  7  /

Warning: Procedure created with compilation errors.

SQL> SHOW ERRORS
Errors for PROCEDURE TEST:

LINE/COL ERROR
-------- -----------------------------------------------------------------
3/14     PL/SQL: SQL Statement ignored
3/40     PL/SQL: ORA-00942: table or view does not exist
作者: numenhuang    時間: 2007-09-10 16:08
SQL> SHOW USER
USER is "FSZW_LSGJ"

sql>select * from COMMON_LSGJ.IM_PR_NOSECT where rownum<10;

如果報錯
connect system
grant select on COMMON_LSGJ.IM_PR_NOSECT to FSZW_LSGJ;
作者: gz_xuhaoz    時間: 2007-09-10 16:09
標題: 回復(fù) #16 numenhuang 的帖子
SQL> select count(*) from  COMMON_LSGJ.IM_PR_NOSECT;

  COUNT(*)
----------
     10423

SQL>
作者: numenhuang    時間: 2007-09-10 16:11
sql>select * from COMMON_LSGJ.IM_PR_NOSECT where rownum<10;
作者: gz_xuhaoz    時間: 2007-09-10 16:13
標題: 回復(fù) #18 numenhuang 的帖子
可以的,沒有問題。
作者: numenhuang    時間: 2007-09-10 16:16
原帖由 gz_xuhaoz 于 2007-9-10 16:13 發(fā)表
可以的,沒有問題。


如果這樣的話
SQL> create or replace procedure test
  2  as
  3  cursor cc is select * from COMMON_LSGJ.IM_PR_NOSECT;
  4  begin
  5  null;
  6  end;
  7  /
還會報錯?
作者: gz_xuhaoz    時間: 2007-09-10 16:19
標題: 回復(fù) #20 numenhuang 的帖子
是的, 見15樓。
作者: numenhuang    時間: 2007-09-10 16:32
測試一下:

connect COMMON_LSGJ
grant select on COMMON_LSGJ.IM_PR_NOSECT to FSZW_LSGJ;

connect FSZW_LSGJ
SQL> create or replace procedure test
  2  as
  3  cursor cc is select * from COMMON_LSGJ.IM_PR_NOSECT;
  4  begin
  5  null;
  6  end;
  7  /

我的分析是select on COMMON_LSGJ.IM_PR_NOSECT你是通過role grant給FSZW_LSGJ
這在pl/sql中是不可以的。
作者: gz_xuhaoz    時間: 2007-09-10 16:37
原帖由 numenhuang 于 2007-9-10 16:32 發(fā)表
測試一下:

connect COMMON_LSGJ
grant select on COMMON_LSGJ.IM_PR_NOSECT to FSZW_LSGJ;

connect FSZW_LSGJ
SQL> create or replace procedure test
  2  as
  3  cursor cc is select * from COM ...


不錯,授權(quán)以后,就可以直接使用視圖來創(chuàng)建過程了.


3Q!
作者: chunde    時間: 2007-09-11 17:10
提示: 作者被禁止或刪除 內(nèi)容自動屏蔽




歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2