{"id":291,"date":"2012-12-24T15:53:00","date_gmt":"1970-01-01T00:00:00","guid":{"rendered":"http:\/\/www.yazilimmutfagi.com\/?p=291"},"modified":"2012-12-24T15:53:00","modified_gmt":"1970-01-01T00:00:00","slug":"plsql-ora-00942-table-or-view-does-not-exist","status":"publish","type":"post","link":"https:\/\/www.yazilimmutfagi.com\/index.php\/2012\/12\/24\/plsql-ora-00942-table-or-view-does-not-exist\/","title":{"rendered":"PL\/SQL: ORA-00942: table or view does not exist"},"content":{"rendered":"<h3>\n\tPL\/SQL: ORA-00942: table or view does not exist<\/h3>\n<pre class=\"brush:sql\">\nPL-SQL scripti i&ccedil;eren bir job, prosed&uuml;re \nolustururken asagidaki hatayi alabiliiz.\nORA-12012: error on auto execute of job 222\nORA-06550: line 8, column 18:\nPL\/SQL: ORA-00942: table or view does not exist\n<\/pre>\n<p>\n\tProcedure i&ccedil;erisinde kullandigimiz tablonun oldugundan eminiz ve gerekli yetkiler saglayan role de bulunmakta. Buna ragmen yukardaki hata aliniyor olabilir.<\/p>\n<p>\n\tHatanin nedeni , procedure veya job olustururken farkli bir semanin tablosunu kullanirken DML hakki direk verilmelidir. Bir role ile verilen haklar yukardaki gibi bir sorun olmasina neden olacaktir. Asagidaki gibi bir study case ile sorunu ve &ccedil;&ouml;z&uuml;m&uuml; g&ouml;rebiliriz.<\/p>\n<p>\n\t**user_a ile login olalim;<\/p>\n<pre class=\"brush:sql\">\ncreate table user_a.test_tablo \n(\nid number,\nname varchar2(50)\n);\nTable created.\n\ninsert into user_a.TEST_TABLO  values (1,&#39;sss&#39;)\n1 row inserted.\n\ninsert into user_a.TEST_TABLO  values (2,&#39;qwerty&#39;);\n1 row inserted.\n\ninsert into user_a.TEST_TABLO  values (3,&#39;aaaaa&#39;);\n1 row inserted.\n\ncreate role test_role;\nRole created.\n\ngrant select on user_a.test_tablo to test_role; \nGrant succeeded.\n \ngrant test_role to user_b;\nGrant succeeded.\n<\/pre>\n<p>\n\t**Simdi user_b ile login olalim;<\/p>\n<pre class=\"brush:sql\">\nselect * from user_a.test_tablo; --sorunsuz , &ccedil;alisti\n declare\n   v_name varchar2(50);\n   begin\n   select t.name into v_name from user_a.test_tablo t where t.id=3;\n   dbms_output.put_line(&#39;3 nolu kayit  :&#39;||v_name);\n   end;\n   \/ \n   --PL\/SQL procedure successfully completed.\n<\/pre>\n<p>\n\tBuraya kadar hi&ccedil;bir sorun olmadan &ccedil;alisti. verdigimiz role ile gerekli yetkiler verildiginden sorun olmadi. DML islemini PLSQL i&ccedil;inde veya guery ile kullanirken sorun olmuyor.<\/p>\n<pre class=\"brush:sql\">\ncreate or replace procedure user_b.test_proc as\n    v_name varchar2(50);\n    begin\n    select t.name into v_name from user_a.test_tablo t where t.id=3;\n    dbms_output.put_line(&#39;3 nolu kayit  :&#39;||v_name);\n    end test_proc;  \n   \/ \n \nWarning: compiled but with compilation errors\n\n[Warning] ORA-24344: derleme hatasi ile basardi\n4\/45    PL\/SQL: ORA-00942: table or view does not exist\n4\/5     PL\/SQL: SQL Statement ignored\n (14: 0): Warning: compiled but with compilation errors\n<\/pre>\n<p>\n\tG&ouml;r&uuml;ld&uuml;g&uuml; gibi procedure i&ccedil;inde daha &ouml;nce &ccedil;alistirdigimiz PLSQL olmasina ragmen sorun verdi.<\/p>\n<p>\n\tSimdi grantlari role kullanmadan, direk verelim.<\/p>\n<pre class=\"brush:sql\">\ngrant select on test_tablo to user_b;\nGrant complete.\n\ncreate or replace procedure user_b.test_proc as\n    v_name varchar2(50);\n    begin\n    select t.name into v_name from user_a.test_tablo t where t.id=3;\n    dbms_output.put_line(&#39;3 nolu kayit  :&#39;||v_name);\n    end test_proc;  \n   \/ \n\nProcedure created.\n<\/pre>\n<p>\n\tUser_b, veritabaninda dba role sahip olsa bile user_a nin tablosnu bir procedure i&ccedil;erinsde kullnmasi i&ccedil;in yine direk grant&rsquo;a ihtiya&ccedil; olur.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PL-SQL scripti i&#231;eren bir job, prosed&#252;re olustururken &quot;ORA-12012: error on auto execute of job 222 ORA-06550: line 8, column 18: PL\/SQL: ORA-00942: table or view does not exist&quot;hatasi alabiliiz.<\/p>\n","protected":false},"author":558,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[423],"tags":[4094,3862,3915,4686],"_links":{"self":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts\/291"}],"collection":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/users\/558"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/comments?post=291"}],"version-history":[{"count":0,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}