{"id":14415,"date":"2017-02-28T23:17:07","date_gmt":"2017-02-28T23:17:07","guid":{"rendered":"http:\/\/www.erpschools.com\/?p=14415"},"modified":"2023-04-03T22:49:14","modified_gmt":"2023-04-03T22:49:14","slug":"oracle-apps-custom-table-org-access-control-policy","status":"publish","type":"post","link":"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy","title":{"rendered":"Oracle Apps Custom Table with ORG Access Control policy"},"content":{"rendered":"\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<p><span style=\"text-decoration: underline;\">Step-1:<\/span> Create Table &amp; Insert data<\/p>\n\n\n\n<p>create table xxcus.xx_tmp_all(id number, name varchar2(100), org_id number);<\/p>\n\n\n\n<p>Replace XXCUS is with your custom schema name. Also make sure to have ORG_ID column and table name suffix as _ALL.<br><code>insert into xxcus.xx_tmp_all values (1,'a',201);<\/code><\/p>\n\n\n\n<p>insert into xxcus.xx_tmp_all values (2,&#8217;b&#8217;,204);<\/p>\n\n\n\n<p>COMMIT;<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\">Step-2<\/span>: Create synonyms<br><code>CREATE OR REPLACE SYNONYM apps.xx_tmp_all FOR xxcus.xx_tmp_all;<\/code><\/p>\n\n\n\n<p>CREATE OR REPLACE SYNONYM apps.xx_tmp FOR xxcus.xx_tmp_all;<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\">Step-3<\/span>: Create Policy<br><code>begin<br>\ndbms_rls.add_policy (<br>\nobject_schema =&gt; 'APPS',<br>\nobject_name =&gt; 'XX_TMP',<br>\npolicy_name =&gt; 'ORG_SEC',<br>\nfunction_schema =&gt; 'APPS',<br>\npolicy_function =&gt; 'MO_GLOBAL.ORG_SECURITY',<br>\nstatement_types =&gt; 'INSERT, UPDATE, DELETE, SELECT',<br>\nupdate_check =&gt; TRUE,<br>\nenable =&gt; TRUE,<br>\nstatic_policy =&gt; FALSE,<br>\npolicy_type =&gt; NULL,<br>\nlong_predicate =&gt; FALSE,<br>\nsec_relevant_cols =&gt; NULL,<br>\nsec_relevant_cols_opt =&gt; NULL<br>\n);<br>\nend;<\/code><br><span style=\"text-decoration: underline;\">Step-4<\/span>: Query Data<br><code>select * from apps.xx_tmp; -- No data retrieved<\/code><\/p>\n\n\n\n<p>EXEC MO_GLOBAL.SET_POLICY_CONTEXT(&#8216;S&#8217;,201);<\/p>\n\n\n\n<p>select * from apps.xx_tmp; &#8212; 201 record retrieved<\/p>\n\n\n\n<p>EXEC MO_GLOBAL.SET_POLICY_CONTEXT(&#8216;S&#8217;,204);<\/p>\n\n\n\n<p>select * from apps.xx_tmp; &#8212; 204 record retrieved<\/p>\n\n\n\n<p>We can drop by policy with the below command.<br><code>begin<br>\ndbms_rls.drop_policy ('APPS','XX_TEMP','ORG_SEC');<br>\nend;<\/code><\/p>\n\n\n\n<p>Additional Information<\/p>\n\n\n\n<p><code>select * from dba_policies; -- should give all existing policies<\/code><\/p>\n\n\n\n<p>Check session org access<\/p>\n\n\n\n<p><code><br>\nDECLARE<br>\nRET VARCHAR2(100);<br>\norg NUMBER;<br>\nBEGIN<br>\nRET := MO_GLOBAL.CHECK_ACCESS (201); -- change org for which you need to check access<br>\norg := mo_global.get_current_org_id;<br>\nDBMS_OUTPUT.PUT_LINE (RET);<br>\ndbms_output.put_line (org);<br>\nEND;<br>\n<\/code><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Oracle RLS Policy to enable Multi org security for custom objects \/ tables<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,489],"tags":[243,548,545,549,112,547,546],"class_list":["post-14415","post","type-post","status-publish","format-standard","hentry","category-scripts","category-sqlpl-sql","tag-apps-2","tag-context","tag-custom-table","tag-dbms_rls-add_policy","tag-oracle","tag-org","tag-policy"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Oracle Apps Custom Table with ORG Access Control policy - erpSchools<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prudhvi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy#article\",\"isPartOf\":{\"@id\":\"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy\"},\"author\":{\"name\":\"Prudhvi\",\"@id\":\"https:\/\/erpschools.com\/erps\/#\/schema\/person\/dbed9bb7fb66aa7a700fc565da024512\"},\"headline\":\"Oracle Apps Custom Table with ORG Access Control policy\",\"datePublished\":\"2017-02-28T23:17:07+00:00\",\"dateModified\":\"2023-04-03T22:49:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy\"},\"wordCount\":125,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/erpschools.com\/erps\/#organization\"},\"keywords\":[\"apps\",\"context\",\"custom table\",\"dbms_rls.add_policy\",\"Oracle\",\"org\",\"policy\"],\"articleSection\":[\"Scripts\",\"SQL\/PL-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy\",\"url\":\"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy\",\"name\":\"Oracle Apps Custom Table with ORG Access Control policy - erpSchools\",\"isPartOf\":{\"@id\":\"https:\/\/erpschools.com\/erps\/#website\"},\"datePublished\":\"2017-02-28T23:17:07+00:00\",\"dateModified\":\"2023-04-03T22:49:14+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/erpschools.com\/erps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Oracle Apps Custom Table with ORG Access Control policy\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/erpschools.com\/erps\/#website\",\"url\":\"https:\/\/erpschools.com\/erps\/\",\"name\":\"erpSchools\",\"description\":\"Oracle Apps\",\"publisher\":{\"@id\":\"https:\/\/erpschools.com\/erps\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/erpschools.com\/erps\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/erpschools.com\/erps\/#organization\",\"name\":\"erpSchools\",\"url\":\"https:\/\/erpschools.com\/erps\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/erpschools.com\/erps\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/erpschools.com\/erps\/wp-content\/uploads\/img\/erps_logo7.png\",\"contentUrl\":\"https:\/\/erpschools.com\/erps\/wp-content\/uploads\/img\/erps_logo7.png\",\"width\":250,\"height\":60,\"caption\":\"erpSchools\"},\"image\":{\"@id\":\"https:\/\/erpschools.com\/erps\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"http:\/\/facebook.com\/erpschools\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/erpschools.com\/erps\/#\/schema\/person\/dbed9bb7fb66aa7a700fc565da024512\",\"name\":\"Prudhvi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/erpschools.com\/erps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/488cec3605845b95cb20e60c67a8f5c7e74b65a305525c8006315d524f120db9?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/488cec3605845b95cb20e60c67a8f5c7e74b65a305525c8006315d524f120db9?s=96&d=blank&r=g\",\"caption\":\"Prudhvi\"},\"sameAs\":[\"http:\/\/www.erpschools.com\"],\"url\":\"https:\/\/erpschools.com\/erps\/author\/prudhvi\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Oracle Apps Custom Table with ORG Access Control policy - erpSchools","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy","twitter_misc":{"Written by":"Prudhvi","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy#article","isPartOf":{"@id":"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy"},"author":{"name":"Prudhvi","@id":"https:\/\/erpschools.com\/erps\/#\/schema\/person\/dbed9bb7fb66aa7a700fc565da024512"},"headline":"Oracle Apps Custom Table with ORG Access Control policy","datePublished":"2017-02-28T23:17:07+00:00","dateModified":"2023-04-03T22:49:14+00:00","mainEntityOfPage":{"@id":"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy"},"wordCount":125,"commentCount":0,"publisher":{"@id":"https:\/\/erpschools.com\/erps\/#organization"},"keywords":["apps","context","custom table","dbms_rls.add_policy","Oracle","org","policy"],"articleSection":["Scripts","SQL\/PL-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy#respond"]}]},{"@type":"WebPage","@id":"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy","url":"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy","name":"Oracle Apps Custom Table with ORG Access Control policy - erpSchools","isPartOf":{"@id":"https:\/\/erpschools.com\/erps\/#website"},"datePublished":"2017-02-28T23:17:07+00:00","dateModified":"2023-04-03T22:49:14+00:00","breadcrumb":{"@id":"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/erpschools.com\/erps\/scripts\/oracle-apps-custom-table-org-access-control-policy#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/erpschools.com\/erps"},{"@type":"ListItem","position":2,"name":"Oracle Apps Custom Table with ORG Access Control policy"}]},{"@type":"WebSite","@id":"https:\/\/erpschools.com\/erps\/#website","url":"https:\/\/erpschools.com\/erps\/","name":"erpSchools","description":"Oracle Apps","publisher":{"@id":"https:\/\/erpschools.com\/erps\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/erpschools.com\/erps\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/erpschools.com\/erps\/#organization","name":"erpSchools","url":"https:\/\/erpschools.com\/erps\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/erpschools.com\/erps\/#\/schema\/logo\/image\/","url":"https:\/\/erpschools.com\/erps\/wp-content\/uploads\/img\/erps_logo7.png","contentUrl":"https:\/\/erpschools.com\/erps\/wp-content\/uploads\/img\/erps_logo7.png","width":250,"height":60,"caption":"erpSchools"},"image":{"@id":"https:\/\/erpschools.com\/erps\/#\/schema\/logo\/image\/"},"sameAs":["http:\/\/facebook.com\/erpschools"]},{"@type":"Person","@id":"https:\/\/erpschools.com\/erps\/#\/schema\/person\/dbed9bb7fb66aa7a700fc565da024512","name":"Prudhvi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/erpschools.com\/erps\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/488cec3605845b95cb20e60c67a8f5c7e74b65a305525c8006315d524f120db9?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/488cec3605845b95cb20e60c67a8f5c7e74b65a305525c8006315d524f120db9?s=96&d=blank&r=g","caption":"Prudhvi"},"sameAs":["http:\/\/www.erpschools.com"],"url":"https:\/\/erpschools.com\/erps\/author\/prudhvi"}]}},"_links":{"self":[{"href":"https:\/\/erpschools.com\/erps\/wp-json\/wp\/v2\/posts\/14415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/erpschools.com\/erps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/erpschools.com\/erps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/erpschools.com\/erps\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/erpschools.com\/erps\/wp-json\/wp\/v2\/comments?post=14415"}],"version-history":[{"count":4,"href":"https:\/\/erpschools.com\/erps\/wp-json\/wp\/v2\/posts\/14415\/revisions"}],"predecessor-version":[{"id":14619,"href":"https:\/\/erpschools.com\/erps\/wp-json\/wp\/v2\/posts\/14415\/revisions\/14619"}],"wp:attachment":[{"href":"https:\/\/erpschools.com\/erps\/wp-json\/wp\/v2\/media?parent=14415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/erpschools.com\/erps\/wp-json\/wp\/v2\/categories?post=14415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/erpschools.com\/erps\/wp-json\/wp\/v2\/tags?post=14415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}