<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Standard for Database Development &#8211; Getting rid of USER from PL/SQL and SQL &#8211; no longer is USER equivalent to End User</title>
	<atom:link href="http://technology.amis.nl/2005/09/08/standard-for-database-development-getting-rid-of-user-from-plsql-and-sql-no-longer-is-user-equivalent-to-end-user/feed/" rel="self" type="application/rss+xml" />
	<link>http://technology.amis.nl/2005/09/08/standard-for-database-development-getting-rid-of-user-from-plsql-and-sql-no-longer-is-user-equivalent-to-end-user/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=standard-for-database-development-getting-rid-of-user-from-plsql-and-sql-no-longer-is-user-equivalent-to-end-user</link>
	<description></description>
	<lastBuildDate>Fri, 12 Apr 2013 10:04:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: IT-eye Weblog &#187; Oracle Proxy Users</title>
		<link>http://technology.amis.nl/2005/09/08/standard-for-database-development-getting-rid-of-user-from-plsql-and-sql-no-longer-is-user-equivalent-to-end-user/#comment-2423</link>
		<dc:creator>IT-eye Weblog &#187; Oracle Proxy Users</dc:creator>
		<pubDate>Sat, 15 Apr 2006 09:49:27 +0000</pubDate>
		<guid isPermaLink="false">/?p=777#comment-2423</guid>
		<description><![CDATA[[...] In the Amis Technology corner Lucas jellema is discussing the problem with Oracle&#8217;s USER: Standard for Database Development - Getting rid of USER from PL/SQL and SQL - no longer is USER equivalent to End User. Many applications use USER to determine who&#8217;s logged on to the database. Security is based on USER and roles. But this only works if every user actually logs in using his own account. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] In the Amis Technology corner Lucas jellema is discussing the problem with Oracle&#8217;s USER: Standard for Database Development &#8211; Getting rid of USER from PL/SQL and SQL &#8211; no longer is USER equivalent to End User. Many applications use USER to determine who&#8217;s logged on to the database. Security is based on USER and roles. But this only works if every user actually logs in using his own account. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lucas Jellema</title>
		<link>http://technology.amis.nl/2005/09/08/standard-for-database-development-getting-rid-of-user-from-plsql-and-sql-no-longer-is-user-equivalent-to-end-user/#comment-2422</link>
		<dc:creator>Lucas Jellema</dc:creator>
		<pubDate>Wed, 14 Sep 2005 14:16:45 +0000</pubDate>
		<guid isPermaLink="false">/?p=777#comment-2422</guid>
		<description><![CDATA[The benefit of using application contexts is twofold: changes in the values are directly picked up. Values in the package variables are only picked up if you enforce that the policy function is called again after a change is made in the values of the package variables. In Oracle 9i, the Policy Function is called only once per session - the first time a query is run on the table or view the policy function is defined against - unless the policy function depends on the SYS_CONTEXT function. In 10g, you can specify for policy functions if they are static, dynamic (invoked every time a query is run) or context sensitive.

The second benefit of using the Application Context over Package Functions is that a reference to an Application Context in a where clause is resolved like a bind-parameter and evaluated only once per query, whereas a package function is called over an over again for every record that is evaluated, even if the function returns the same value for every call.]]></description>
		<content:encoded><![CDATA[<p>The benefit of using application contexts is twofold: changes in the values are directly picked up. Values in the package variables are only picked up if you enforce that the policy function is called again after a change is made in the values of the package variables. In Oracle 9i, the Policy Function is called only once per session &#8211; the first time a query is run on the table or view the policy function is defined against &#8211; unless the policy function depends on the SYS_CONTEXT function. In 10g, you can specify for policy functions if they are static, dynamic (invoked every time a query is run) or context sensitive.</p>
<p>The second benefit of using the Application Context over Package Functions is that a reference to an Application Context in a where clause is resolved like a bind-parameter and evaluated only once per query, whereas a package function is called over an over again for every record that is evaluated, even if the function returns the same value for every call.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Slikker</title>
		<link>http://technology.amis.nl/2005/09/08/standard-for-database-development-getting-rid-of-user-from-plsql-and-sql-no-longer-is-user-equivalent-to-end-user/#comment-2421</link>
		<dc:creator>Eric Slikker</dc:creator>
		<pubDate>Wed, 14 Sep 2005 07:18:27 +0000</pubDate>
		<guid isPermaLink="false">/?p=777#comment-2421</guid>
		<description><![CDATA[Instead of using SYS_CONTEXT, I&#039;m using package_variables. This gives me more flexibility.
In a logon trigger, I can fill the &#039;Context-user&#039; and extra &#039;context-data&#039;.
I also fill an internal table with RLS-clauses.

Every VPN-definition is set like:

begin
  DBMS_RLS.ADD_POLICY (
    object_schema   =&gt; &#039;xxx_OWN&#039;,
    object_name     =&gt; &#039;COMPANIES&#039;,
    policy_name     =&gt; &#039;RLS_COMPANIES&#039;,
    function_schema =&gt; &#039;SYSBEHEER&#039;,
    policy_function =&gt; &#039;SBR$AUTORISATIE.RLS_autorisatie&#039;
   );
end;

The function SBR$AUTORISATIE.RLS_autorisatie returns the WHERE-clause for the current user.
This clause can be different for different users. This can be handy for batch-processing.

FUNCTION SBR$AUTORISATIE.RLS_AUTORISATIE
(p_obj_schema  VARCHAR2
,p_obj_name    VARCHAR2)
RETURN VARCHAR2
IS
  t_predicate VARCHAR2(4000) := &#039;1=1&#039;;
BEGIN
  IF t_rls_aut_tab.exists (p_obj_name)
  THEN
    t_predicate := t_rls_aut_tab(p_obj_name);
  END IF;
  RETURN (t_predicate);
END RLS_AUTORISATIE;

By using the extra context-data, I don&#039;t need the USER_column in my tables.
Users can only access companies they&#039;re authorised for:

SELECT *
FROM   COMPANIES
WHERE  sbr$autorisatie.autorisatie_company (company_code) = sbr.vtrue;


FUNCTION autorisatie_company
(p_company_code   VARCHAR2)
RETURN VARCHAR2
IS
  t_return sbr.tp_chr%TYPE := sbr.vfalse;
BEGIN
  IF t_aut_company_tab.exists (p_company_code)
  THEN
    t_return := sbr.vtrue;
  END IF;
  RETURN (t_return);
END autorisatie_company;

For the Batch-usser, the where-clause from the function SBR$AUTORISATIE.RLS_AUTORISATIE results in:

SELECT *
FROM   COMPANIES
WHERE  1=1;

Other tables can depend on this authorised comany table:

SELECT*
FROM   COMPANY_LOCATIONS  CLS
WHERE  EXISTS (SELECT 1 FROM COMPANIES CPS WHERE CPS.COMPANY_CODE = CLS.COMPANY_CODE)

And for batch-users the where_clause can be:

SELECT*
FROM   COMPANY_LOCATIONS  CLS
WHERE  1=1]]></description>
		<content:encoded><![CDATA[<p>Instead of using SYS_CONTEXT, I&#8217;m using package_variables. This gives me more flexibility.<br />
In a logon trigger, I can fill the &#8216;Context-user&#8217; and extra &#8216;context-data&#8217;.<br />
I also fill an internal table with RLS-clauses.</p>
<p>Every VPN-definition is set like:</p>
<p>begin<br />
  DBMS_RLS.ADD_POLICY (<br />
    object_schema   => &#8216;xxx_OWN&#8217;,<br />
    object_name     => &#8216;COMPANIES&#8217;,<br />
    policy_name     => &#8216;RLS_COMPANIES&#8217;,<br />
    function_schema => &#8216;SYSBEHEER&#8217;,<br />
    policy_function => &#8216;SBR$AUTORISATIE.RLS_autorisatie&#8217;<br />
   );<br />
end;</p>
<p>The function SBR$AUTORISATIE.RLS_autorisatie returns the WHERE-clause for the current user.<br />
This clause can be different for different users. This can be handy for batch-processing.</p>
<p>FUNCTION SBR$AUTORISATIE.RLS_AUTORISATIE<br />
(p_obj_schema  VARCHAR2<br />
,p_obj_name    VARCHAR2)<br />
RETURN VARCHAR2<br />
IS<br />
  t_predicate VARCHAR2(4000) := &#8217;1=1&#8242;;<br />
BEGIN<br />
  IF t_rls_aut_tab.exists (p_obj_name)<br />
  THEN<br />
    t_predicate := t_rls_aut_tab(p_obj_name);<br />
  END IF;<br />
  RETURN (t_predicate);<br />
END RLS_AUTORISATIE;</p>
<p>By using the extra context-data, I don&#8217;t need the USER_column in my tables.<br />
Users can only access companies they&#8217;re authorised for:</p>
<p>SELECT *<br />
FROM   COMPANIES<br />
WHERE  sbr$autorisatie.autorisatie_company (company_code) = sbr.vtrue;</p>
<p>FUNCTION autorisatie_company<br />
(p_company_code   VARCHAR2)<br />
RETURN VARCHAR2<br />
IS<br />
  t_return sbr.tp_chr%TYPE := sbr.vfalse;<br />
BEGIN<br />
  IF t_aut_company_tab.exists (p_company_code)<br />
  THEN<br />
    t_return := sbr.vtrue;<br />
  END IF;<br />
  RETURN (t_return);<br />
END autorisatie_company;</p>
<p>For the Batch-usser, the where-clause from the function SBR$AUTORISATIE.RLS_AUTORISATIE results in:</p>
<p>SELECT *<br />
FROM   COMPANIES<br />
WHERE  1=1;</p>
<p>Other tables can depend on this authorised comany table:</p>
<p>SELECT*<br />
FROM   COMPANY_LOCATIONS  CLS<br />
WHERE  EXISTS (SELECT 1 FROM COMPANIES CPS WHERE CPS.COMPANY_CODE = CLS.COMPANY_CODE)</p>
<p>And for batch-users the where_clause can be:</p>
<p>SELECT*<br />
FROM   COMPANY_LOCATIONS  CLS<br />
WHERE  1=1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Flack</title>
		<link>http://technology.amis.nl/2005/09/08/standard-for-database-development-getting-rid-of-user-from-plsql-and-sql-no-longer-is-user-equivalent-to-end-user/#comment-2420</link>
		<dc:creator>John Flack</dc:creator>
		<pubDate>Tue, 13 Sep 2005 12:51:14 +0000</pubDate>
		<guid isPermaLink="false">/?p=777#comment-2420</guid>
		<description><![CDATA[Good article - I&#039;ve been thinking about the need for alternatives to USER for some time, but hadn&#039;t come up with a solution I
liked.  I&#039;m not sure about using an application context however.  Shouldn&#039;t this be a database-wide (or even enterprise-wide)
solution?  After all, a single user may have access to more than one application.  I have a schema called COMMON, with the same
objects and procedures in all of my databases - things that are granted to PUBLIC with PUBLIC synonyms.  Maybe the identity
context should be part of COMMON?]]></description>
		<content:encoded><![CDATA[<p>Good article &#8211; I&#8217;ve been thinking about the need for alternatives to USER for some time, but hadn&#8217;t come up with a solution I<br />
liked.  I&#8217;m not sure about using an application context however.  Shouldn&#8217;t this be a database-wide (or even enterprise-wide)<br />
solution?  After all, a single user may have access to more than one application.  I have a schema called COMMON, with the same<br />
objects and procedures in all of my databases &#8211; things that are granted to PUBLIC with PUBLIC synonyms.  Maybe the identity<br />
context should be part of COMMON?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oded M</title>
		<link>http://technology.amis.nl/2005/09/08/standard-for-database-development-getting-rid-of-user-from-plsql-and-sql-no-longer-is-user-equivalent-to-end-user/#comment-2419</link>
		<dc:creator>Oded M</dc:creator>
		<pubDate>Tue, 13 Sep 2005 07:06:01 +0000</pubDate>
		<guid isPermaLink="false">/?p=777#comment-2419</guid>
		<description><![CDATA[didnt used proxy user for a long time now, but if i remember correctly USER will give the proxy user name. am I wrong?]]></description>
		<content:encoded><![CDATA[<p>didnt used proxy user for a long time now, but if i remember correctly USER will give the proxy user name. am I wrong?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lucas</title>
		<link>http://technology.amis.nl/2005/09/08/standard-for-database-development-getting-rid-of-user-from-plsql-and-sql-no-longer-is-user-equivalent-to-end-user/#comment-2418</link>
		<dc:creator>Lucas</dc:creator>
		<pubDate>Tue, 13 Sep 2005 07:00:13 +0000</pubDate>
		<guid isPermaLink="false">/?p=777#comment-2418</guid>
		<description><![CDATA[Review by Pete Finnigan on &lt;a href=&quot;http://www.petefinnigan.com/weblog/archives/00000549.htm&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://www.petefinnigan.com/weblog/archives/00000549.htm&lt;/a&gt;
09/12/2005: &quot;Amis talks about the need to remove USER from PL/SQL and SQL code&quot;


I saw a great article on the Amis blog a few days ago and made a note to have a look and talk about it here. The article is written by Lucas Jellema and is titled &quot; Standard for Database....[Read More]

I saw a great article on the Amis blog a few days ago and made a note to have a look and talk about it here. The article is written by Lucas Jellema and is titled &quot;Standard for Database Development - Getting rid of USER from PL/SQL and SQL - no longer is USER equivalent to End User&quot;. This is a great article that talks about the need to get rid of the USER pseudo function from older code written in the days when all database users had their own database account and using the function did return the correct user. This was in the days before proxy users and connection pooling. Lucas starts with the reasons USER was used and the implications of using it now and why it should be removed and the fact that he is saying it shouldnâ€™t be removed in all cases. Lucas goes on to show some examples of a home grown application user table and also a VPD example. He goes on to give examples of how the user might be set and the issues of application servers, middle tiers and logon triggers. Lucas also talks about the fact that the use of USER translates to a select from dual and how this has improved in 10g.

Great paper and well worth a read.]]></description>
		<content:encoded><![CDATA[<p>Review by Pete Finnigan on <a href="http://www.petefinnigan.com/weblog/archives/00000549.htm" target="_blank" rel="nofollow">http://www.petefinnigan.com/weblog/archives/00000549.htm</a><br />
09/12/2005: &#8220;Amis talks about the need to remove USER from PL/SQL and SQL code&#8221;</p>
<p>I saw a great article on the Amis blog a few days ago and made a note to have a look and talk about it here. The article is written by Lucas Jellema and is titled &#8221; Standard for Database&#8230;.[Read More]</p>
<p>I saw a great article on the Amis blog a few days ago and made a note to have a look and talk about it here. The article is written by Lucas Jellema and is titled &#8220;Standard for Database Development &#8211; Getting rid of USER from PL/SQL and SQL &#8211; no longer is USER equivalent to End User&#8221;. This is a great article that talks about the need to get rid of the USER pseudo function from older code written in the days when all database users had their own database account and using the function did return the correct user. This was in the days before proxy users and connection pooling. Lucas starts with the reasons USER was used and the implications of using it now and why it should be removed and the fact that he is saying it shouldnâ€™t be removed in all cases. Lucas goes on to show some examples of a home grown application user table and also a VPD example. He goes on to give examples of how the user might be set and the issues of application servers, middle tiers and logon triggers. Lucas also talks about the fact that the use of USER translates to a select from dual and how this has improved in 10g.</p>
<p>Great paper and well worth a read.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ronald</title>
		<link>http://technology.amis.nl/2005/09/08/standard-for-database-development-getting-rid-of-user-from-plsql-and-sql-no-longer-is-user-equivalent-to-end-user/#comment-2417</link>
		<dc:creator>ronald</dc:creator>
		<pubDate>Fri, 09 Sep 2005 05:36:07 +0000</pubDate>
		<guid isPermaLink="false">/?p=777#comment-2417</guid>
		<description><![CDATA[Very clear exercise!]]></description>
		<content:encoded><![CDATA[<p>Very clear exercise!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott P</title>
		<link>http://technology.amis.nl/2005/09/08/standard-for-database-development-getting-rid-of-user-from-plsql-and-sql-no-longer-is-user-equivalent-to-end-user/#comment-2416</link>
		<dc:creator>Scott P</dc:creator>
		<pubDate>Thu, 08 Sep 2005 15:47:26 +0000</pubDate>
		<guid isPermaLink="false">/?p=777#comment-2416</guid>
		<description><![CDATA[Great article. Just yesterday, I worked on this in an application of mine. My need was for archiving/journaling changes to a table. I sought a different approach that does not rely on the application to set the context as I wanted to capture changes being done with other end user tools. (sql plus, toad etc.) I chose to grab osuser and module from v$context and use that instead. It is in testing now, so I am not sure if it will work in all situations, but so far, so good.]]></description>
		<content:encoded><![CDATA[<p>Great article. Just yesterday, I worked on this in an application of mine. My need was for archiving/journaling changes to a table. I sought a different approach that does not rely on the application to set the context as I wanted to capture changes being done with other end user tools. (sql plus, toad etc.) I chose to grab osuser and module from v$context and use that instead. It is in testing now, so I am not sure if it will work in all situations, but so far, so good.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
