<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Computed column function permission in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813729#M4844572</link>
    <description>&lt;P&gt;I can reproduce your results with 12.0.1.3484 (and that function explicitly declared as DETERMINISTIC). I would agree that this is not expected behaviour IMHO...&lt;/P&gt;</description>
    <pubDate>Tue, 22 Nov 2011 10:42:51 GMT</pubDate>
    <dc:creator>VolkerBarth</dc:creator>
    <dc:date>2011-11-22T10:42:51Z</dc:date>
    <item>
      <title>Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaq-p/13813725</link>
      <description>&lt;P&gt;[SQL Anywhere 12.0.1.3324]&lt;/P&gt;
&lt;P&gt;If I create a computed column that calls a function in its expression then it seems that a user needs both SELECT permission on the table &lt;STRONG&gt;AND&lt;/STRONG&gt; EXECUTE permission on that function in order to retrieve the column's value.&lt;BR /&gt;
&lt;/P&gt;
&lt;P&gt;This surprised me because the help file ('Recalculating computed columns') states that 'Computed columns are not recalculated under the following circumstances: The computed column is queried[...]'&lt;/P&gt;
&lt;P&gt;e.g. if I create a function and table as follows:&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;CREATE&lt;/SPAN&gt; &lt;SPAN class="k"&gt;FUNCTION&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_group&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_function&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;some_chars&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;char&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;4&lt;/SPAN&gt;&lt;SPAN class="p"&gt;))&lt;/SPAN&gt; &lt;SPAN class="k"&gt;RETURNS&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;CHAR&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;4&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; 
&lt;SPAN class="k"&gt;BEGIN&lt;/SPAN&gt; 
    &lt;SPAN class="k"&gt;RETURN&lt;/SPAN&gt; &lt;SPAN class="n"&gt;some_chars&lt;/SPAN&gt; 
&lt;SPAN class="k"&gt;END&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;go&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;CREATE&lt;/SPAN&gt; &lt;SPAN class="k"&gt;TABLE&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_group&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_table&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_column&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;CHAR&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;4&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="n"&gt;COMPUTE&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_group&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_function&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;'ABCD'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)))&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;go&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;GRANT&lt;/SPAN&gt; &lt;SPAN class="k"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="k"&gt;ON&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_group&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_table&lt;/SPAN&gt; &lt;SPAN class="k"&gt;to&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_user&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;then if I connect as a_user and try&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_column&lt;/SPAN&gt; &lt;SPAN class="k"&gt;FROM&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_group&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_table&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;it gives the error 'Permission denied: you do not have permission to execute the procedure "a_function"'&lt;/P&gt;
&lt;P&gt;Is this expected behaviour?&lt;BR /&gt;
&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2011 09:44:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaq-p/13813725</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-22T09:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813729#M4844572</link>
      <description>&lt;P&gt;I can reproduce your results with 12.0.1.3484 (and that function explicitly declared as DETERMINISTIC). I would agree that this is not expected behaviour IMHO...&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2011 10:42:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813729#M4844572</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-11-22T10:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813730#M4844573</link>
      <description>&lt;P&gt;Even stranger, I just realised that SELECTing &lt;EM&gt;any&lt;/EM&gt; column from the table gives the same error&lt;/P&gt;
&lt;P&gt;e.g. if my table definition is now&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;CREATE&lt;/SPAN&gt; &lt;SPAN class="k"&gt;TABLE&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_group&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_table&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_column&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;CHAR&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;4&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="n"&gt;COMPUTE&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_group&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_function&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;'ABCD'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)),&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_column2&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;INTEGER&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;Then doing &lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_column2&lt;/SPAN&gt; &lt;SPAN class="k"&gt;FROM&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_group&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_table&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;Gives the same error, even though the single column I am selecting has nothing to do with the function&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2011 07:09:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813730#M4844573</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-23T07:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813726#M4844569</link>
      <description>&lt;P&gt;Hi Luke,&lt;/P&gt;
&lt;P&gt;I would agree that it's expected that you would need to GRANT EXECUTE permissions on the underlying function to have this configuration work correctly ( &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbadmin/permission-db-objects.html"&gt;&lt;/A&gt;&lt;A href="http://dcx.sybase.com/index.html#1201/en/dbadmin/permission-db-objects.html"&gt;&lt;/A&gt;&lt;A href="http://dcx.sybase.com/index.html#1201/en/dbadmin/permission-db-objects.html"&gt;http://dcx.sybase.com/index.html#1201/en/dbadmin/permission-db-objects.html&lt;/A&gt; ), although I do agree that it's odd that we're requesting permission on this object when we don't explicitly require it for the current operation. This error should probably only happen with DML operations when the current user is actually trying to insert/update/delete against the base table and we require the function permission to update the column(s).&lt;/P&gt;
&lt;P&gt;I have opened internal issue CR #691747 to investigate this issue further. I will update this answer once we can confirm the intended behaviour.&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;&lt;STRONG&gt;Edit:&lt;/STRONG&gt; Engineering has confirmed that &lt;A href="http://sqlanywhere-forum.sap.com/questions/8617/computed-column-function-permission#8864"&gt;Glenn's answer&lt;/A&gt; is the correct behaviour description.&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;Thank you for the behaviour report.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2011 14:50:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813726#M4844569</guid>
      <dc:creator>jeff_albion</dc:creator>
      <dc:date>2011-11-28T14:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813731#M4844574</link>
      <description>&lt;P&gt;Well, I had expected I only do need permissions on those database objects I do explicitly refer to...&lt;/P&gt;
&lt;P&gt;For Luke's sample, I would think this works more like a trigger, i.e. the DML operation itself runs with the permission of the caller but the COMPUTE clause code runs with the permission of the table owner. - Just my 2 cents:)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2011 02:02:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813731#M4844574</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-11-29T02:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813732#M4844575</link>
      <description>&lt;P&gt;&lt;A href="https://sqlanywhere-forum.sap.com/users/108/jeff-albion/"&gt;@Jeff&lt;/A&gt;: thanks for the post&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2011 04:59:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813732#M4844575</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-29T04:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813733#M4844576</link>
      <description>&lt;P&gt;&lt;A href="https://sqlanywhere-forum.sap.com/users/108/jeff-albion/"&gt;@Jeff&lt;/A&gt;: Might the noted CR number relate to a different topic?&lt;/P&gt;
&lt;P&gt;That CR is documented with:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Misleading error messages would have been returned to the client when opening a connection using an invalid DSN. This problem has been fixed.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 29 Nov 2011 05:02:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813733#M4844576</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-11-29T05:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813734#M4844577</link>
      <description>&lt;P&gt;Thanks Volker - I accidentally CC'ed the CR number from &lt;A href="http://sqlanywhere-forum.sap.com/questions/8630/cannot-connect-to-ianywhere-db-net-cf35-ap-on-windows-mobile-61-pro#8676"&gt;the other thread&lt;/A&gt; I replied to. Fixed in the edit now.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2011 11:39:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813734#M4844577</guid>
      <dc:creator>jeff_albion</dc:creator>
      <dc:date>2011-11-29T11:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813727#M4844570</link>
      <description>&lt;P&gt;The answer to this question is more complex than it would seem at first glance. &lt;/P&gt;
&lt;P&gt;Yes, of course it would be reasonable and expected for SQL Anywhere server to build (and verify permissions for) a query with only the column and attribute references that are explicitly required. &lt;/P&gt;
&lt;P&gt;With a computed column, however, things are not that simple. The whole idea of a computed column is to be able to substitute the computed column for a (possibly complex) expression that occurs within the query. Consequently, the server builds &lt;STRONG&gt;each&lt;/STRONG&gt; computed column for every table referenced in the query &lt;STRONG&gt;in case&lt;/STRONG&gt; the server detects that one or more complex expressions can be replaced by a corresponding computed column (and, possibly, utilize an index on that computed column).&lt;/P&gt;
&lt;P&gt;At the moment, when building any expression involving a user-defined function, SQL Anywhere verifies that the user has permission to call that function. Permission checking at query compile time, too, is a conscious decision because it avoids situations where different invocations of seemingly equivalent statements get different behaviour (one works, the other gets a permission error at runtime).&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2011 10:01:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813727#M4844570</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-08T10:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813735#M4844578</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;"Consequently, the server &lt;EM&gt;builds&lt;/EM&gt; each computed column for every table referenced in the query..."&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That comes as a surprise to me - does it mean in the above sample I could query&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;select&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_group&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_function&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;'ABCD'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="k"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;a_group&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;a_table&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;and the engine would detect that this value could be delivered by the computed column &lt;EM&gt;a_column&lt;/EM&gt; and would therefore omit the function call and replace it with the existing column's values?&lt;/P&gt;
&lt;P&gt;Until now, my idea of a computed column was exactly the opposite: I commonly use them to store values automatically that simply depend on other columns (say &lt;EM&gt;col3 = myFn(col1, col2)&lt;/EM&gt;) and &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;that might be expensive to calculate (so they have to be calculated only once - unless the table is ALTERed, of course) and&lt;/LI&gt;
&lt;LI&gt;I want to avoid inconsistencies by preventing application code from independently altering the inherently dependent columns (i.e. to prevent to set col3 without altering col1 or col2 and vice versa).&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;So I would never call the underlying compute expression in a query (&lt;EM&gt;myFn(...)&lt;/EM&gt;) but would usually query the computed column by name (&lt;EM&gt;col3&lt;/EM&gt;)...&lt;/P&gt;
&lt;P&gt;For that type of usage, IMHO the server's expectation to possibly need to replace the compute expression with the column name seems too precautious...&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2011 03:32:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813735#M4844578</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-12-09T03:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813736#M4844579</link>
      <description>&lt;P&gt;That are my expectations too...&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2011 06:15:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813736#M4844579</guid>
      <dc:creator>thomas_duemesnil</dc:creator>
      <dc:date>2011-12-09T06:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813737#M4844580</link>
      <description>&lt;P&gt;I think you need to read the help on computed columns. See&lt;/P&gt;
&lt;P&gt;&lt;A href="http://dcx.sybase.com/index.html#1201/en/dbusage/defining-computed-javause.html*d5e994"&gt;http://dcx.sybase.com/index.html#1201/en/dbusage/defining-computed-javause.html*d5e994&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2011 09:44:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813737#M4844580</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-09T09:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813738#M4844581</link>
      <description>&lt;P&gt;&lt;A href="https://sqlanywhere-forum.sap.com/users/288/glenn/"&gt;@Glenn&lt;/A&gt;: Got me:) - So it's all well documented (and looks somewhat similar to the "View matching" feature w.r.t. materialized views).&lt;/P&gt;
&lt;P&gt;Nevertheless, I still do think that my preferred usage of computed columns makes sense, as well - in the end, it's just the fact that I tend to &lt;STRONG&gt;explicitly use the computed columns in queries&lt;/STRONG&gt; instead of using the underlying expressions and relying on the query engine to find the matching column...&lt;/P&gt;
&lt;P&gt;Or do I have missed your point?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2011 09:58:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813738#M4844581</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-12-09T09:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813739#M4844582</link>
      <description>&lt;P&gt;You can certainly refer to computed columns explicitly, yes. Also keep in mind that the matching isn't exhaustive (it's computationally difficult), rather it's close to "exact match" - that is, if you have a computed column defined as (T.a + T.b + T.c) then that is not going to match a predicate written as (T.c + T.b + T.a) &amp;gt; 5. The same is true for materialized view expression matching.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2011 10:14:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813739#M4844582</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-09T10:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column function permission</title>
      <link>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813728#M4844571</link>
      <description>&lt;P&gt;Based on Glenn's explanation, I would add another approach that&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;omits the need to grant execute
    permission on the UDF for the users who simply are allowed to select from the table and&lt;/LI&gt;
&lt;LI&gt;still ensures that the corresponding column gets a
    calculated value.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;For that, instead of using a computed column, you would use a &lt;STRONG&gt;BEFORE trigger to set the column's value&lt;/STRONG&gt; "automatically". As trigger code runs with the permission of the table owner, &lt;STRONG&gt;there's no need to grant execute permission&lt;/STRONG&gt; for user who simply want to select from the table.&lt;/P&gt;
&lt;P&gt;A small (untested) sample with a given UDF named &lt;EM&gt;myFn()&lt;/EM&gt;:&lt;/P&gt;
&lt;P&gt;Instead of&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;create&lt;/SPAN&gt; &lt;SPAN class="k"&gt;table&lt;/SPAN&gt; &lt;SPAN class="n"&gt;t&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;
   &lt;SPAN class="n"&gt;c1&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;int&lt;/SPAN&gt; &lt;SPAN class="k"&gt;primary&lt;/SPAN&gt; &lt;SPAN class="k"&gt;key&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;
   &lt;SPAN class="n"&gt;c2&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;varchar&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;255&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="n"&gt;compute&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;myFn&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;))&lt;/SPAN&gt;
&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;with need to grant execute on myFn to all users that are allowed to select from t,
you would declare&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;create&lt;/SPAN&gt; &lt;SPAN class="k"&gt;table&lt;/SPAN&gt; &lt;SPAN class="n"&gt;t&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;
   &lt;SPAN class="n"&gt;c1&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;int&lt;/SPAN&gt; &lt;SPAN class="k"&gt;primary&lt;/SPAN&gt; &lt;SPAN class="k"&gt;key&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;
   &lt;SPAN class="n"&gt;c2&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;varchar&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;255&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;

&lt;SPAN class="k"&gt;create&lt;/SPAN&gt; &lt;SPAN class="k"&gt;trigger&lt;/SPAN&gt; &lt;SPAN class="n"&gt;tr_iu_t&lt;/SPAN&gt;
   &lt;SPAN class="k"&gt;before&lt;/SPAN&gt; &lt;SPAN class="k"&gt;insert&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="k"&gt;update&lt;/SPAN&gt; &lt;SPAN class="k"&gt;on&lt;/SPAN&gt; &lt;SPAN class="n"&gt;t&lt;/SPAN&gt;
   &lt;SPAN class="k"&gt;referencing&lt;/SPAN&gt; &lt;SPAN class="k"&gt;new&lt;/SPAN&gt; &lt;SPAN class="k"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;n&lt;/SPAN&gt;
   &lt;SPAN class="k"&gt;for&lt;/SPAN&gt; &lt;SPAN class="k"&gt;each&lt;/SPAN&gt; &lt;SPAN class="k"&gt;row&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;begin&lt;/SPAN&gt; 
   &lt;SPAN class="k"&gt;set&lt;/SPAN&gt; &lt;SPAN class="n"&gt;n&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c2&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;myFn&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;n&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;end&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;Note: I surely don't want to tell that triggers are "easier" than computed columns. I'm just trying to show how you omit the need to grant execute permission here...&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;For a detailed discussion between BEFORE UPDATE triggers and COMPUTED COLUMNs and the dependencies between them, I remember a &lt;A href="http://groups.google.com/group/sybase.public.sqlanywhere.general/browse_frm/thread/6ede905bafd99057/34654720def5608a?lnk=gst&amp;amp;q=Before+update+trigger+and+computed+column#34654720def5608a"&gt;longer thread discussion&lt;/A&gt; with Glenn in the general newsgroup...&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2011 15:04:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/computed-column-function-permission/qaa-p/13813728#M4844571</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-12-11T15:04:42Z</dc:date>
    </item>
  </channel>
</rss>

