存储过程 ORA-00942 表或视图不存在

 


# 存储过程 ORA-00942 表或视图不存在
## 原因分析:
1 大小写
2 权限赋予

## 权限赋予思路:
1 grant ***
2 加入“Authid Current_User” 如
```sql
create or replace procedure P_create_emp2 authid current_user as …………
```

CREATE OR REPLACE PROCEDURE P_STUDENT_TRANSFER Authid Current_User 
AS
  CURSOR abd
  IS
    SELECT ' INSERT INTO BI.TEST_STUDENT  (WBMMC,XXDMC,SJZS,YPCGS,YPBCGS) VALUES ('''  -- 加入“Authid Current_User ” ,解决 表或视图不存在
      || T1.WBM_MC
      ||''','''
      || T2.XXD_MC
      ||''','
      || '(SELECT COUNT(*) FROM '
      ||T2.XXD_YYB_MC
      ||' ),'
      || '(SELECT COUNT(1) FROM '
      || T2.XXD_YYB_MC
      ||' T WHERE T.DJXH IS NOT NULL ),'
      || '(SELECT COUNT(1) FROM '
      || T2.XXD_YYB_MC
      ||' T WHERE T.DJXH IS  NULL ));' AS SQLS
    FROM BI.DM_DSF_WBMXX T1
    LEFT JOIN BI.DSF_XXD_JBXX T2
    ON T1.WBM_DM        =T2.SSWBM_DM
  t_sqls abd%rowtype;
BEGIN

  EXECUTE IMMEDIATE 'TRUNCATE TABLE BI.TEST_STUDENT';    // 清空表的数据
  COMMIT;
  FOR t_sqls IN abd
  LOOP
    BEGIN
      EXECUTE IMMEDIATE t_sqls.SQLS; --  t_sqls.SQLS内不含“;”分号,含分号会报错;此处执行sql
    END;
  END LOOP;
END P_STUDENT_TRANSFER;-- 收尾name一致:P_STUDENT_TRANSFER

 

 

参考:

1. Oracle:Authid Current_User使用  https://www.cnblogs.com/Richardzhu/p/3460985.html

posted @ 2017-11-26 16:16  一度君ヾ華  阅读(3562)  评论(0编辑  收藏  举报