<?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: Materialized view with Parameter? in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840119#M4870962</link>
    <description>&lt;P&gt;No, not at this time. &lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2011 13:34:47 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-04-29T13:34:47Z</dc:date>
    <item>
      <title>Materialized view with Parameter?</title>
      <link>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaq-p/13840118</link>
      <description>&lt;P&gt;Is it possible to create a materialized view which uses a parameter during manual refresh?
Something like &lt;/P&gt;
&lt;LI-CODE lang="sql"&gt;CREATE MATERIALIZED VIEW "DBA"."MyView" in system as 
select * from X where X.date &amp;gt; PARAM
&lt;/LI-CODE&gt;
&lt;P&gt;So that e.g. each week the materialized view can be refreshed to reflect the values of last week or so...&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2011 12:06:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaq-p/13840118</guid>
      <dc:creator>MCMartin</dc:creator>
      <dc:date>2011-04-29T12:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized view with Parameter?</title>
      <link>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840119#M4870962</link>
      <description>&lt;P&gt;No, not at this time. &lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2011 13:34:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840119#M4870962</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-04-29T13:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized view with Parameter?</title>
      <link>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840122#M4870965</link>
      <description>&lt;P&gt;I guess you do not want to use an ordinary view (e.g. something like &lt;/P&gt;
&lt;LI-CODE lang="sql"&gt;select * from x where datediff(dd, x.date, current date) &amp;gt;= 7
&lt;/LI-CODE&gt;
&lt;P&gt;for performance reasons. May a global shared by all temporary table be of help? (I'm aware that temporary tables do not get used by &lt;EM&gt;view matching&lt;/EM&gt;.)&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2011 18:50:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840122#M4870965</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-04-29T18:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized view with Parameter?</title>
      <link>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840120#M4870963</link>
      <description>&lt;P&gt;The workaround I use is an extra table just with the value of the parameter and then in the materialized view:&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="nb"&gt;select&lt;/SPAN&gt; &lt;SPAN class="o"&gt;*&lt;/SPAN&gt; &lt;SPAN class="n"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;X&lt;/SPAN&gt; &lt;SPAN class="n"&gt;where&lt;/SPAN&gt; &lt;SPAN class="n"&gt;X&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;date&lt;/SPAN&gt; &lt;SPAN class="o"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="nb"&gt;select&lt;/SPAN&gt; &lt;SPAN class="n"&gt;max&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;PARAM&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="n"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;paramtable&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;Not elegant but it works.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2011 02:37:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840120#M4870963</guid>
      <dc:creator>MCMartin</dc:creator>
      <dc:date>2011-05-02T02:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized view with Parameter?</title>
      <link>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840123#M4870966</link>
      <description>&lt;P&gt;I'm assuming you are calling the MV explicitly in your queries (instead of relying on view matching)?&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2011 03:17:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840123#M4870966</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-05-02T03:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized view with Parameter?</title>
      <link>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840124#M4870967</link>
      <description>&lt;P&gt;yes, I am not using the view for the optimizer&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2011 07:24:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840124#M4870967</guid>
      <dc:creator>MCMartin</dc:creator>
      <dc:date>2011-05-02T07:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized view with Parameter?</title>
      <link>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840121#M4870964</link>
      <description>&lt;P&gt;If you maintain 'paramtable' with exactly one row representing the current parameter value, then your view can be declared immediate and also can be used for cost-based view matching by the SQL Anywhere Optimizer for queries which don't mention 'paramtable': to let the optimizer know that paramtable has exactly one row, add a primary key column. This is one solution. Other solutions exist as well.&lt;/P&gt;
&lt;P&gt;Example:&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;paramtable&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;PK&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;int&lt;/SPAN&gt; &lt;SPAN class="k"&gt;not&lt;/SPAN&gt; &lt;SPAN class="k"&gt;null&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;A_PARAM&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;int&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;

&lt;SPAN class="k"&gt;insert&lt;/SPAN&gt; &lt;SPAN class="k"&gt;into&lt;/SPAN&gt; &lt;SPAN class="n"&gt;paramtable&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;PK&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="n"&gt;A_PARAM&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="k"&gt;values&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="k"&gt;NULL&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;

&lt;SPAN class="k"&gt;update&lt;/SPAN&gt; &lt;SPAN class="n"&gt;paramtable&lt;/SPAN&gt; &lt;SPAN class="k"&gt;set&lt;/SPAN&gt; &lt;SPAN class="n"&gt;A_PARAM&lt;/SPAN&gt;&lt;SPAN class="o"&gt;=&lt;/SPAN&gt;&lt;SPAN class="n"&gt;PARAM&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="c1"&gt;-- This materialized view can be declared immediate&lt;/SPAN&gt;
&lt;SPAN class="c1"&gt;-- and will be also used by the optimizer if the&lt;/SPAN&gt;
&lt;SPAN class="c1"&gt;-- query references only the table 'X'&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;CREATE&lt;/SPAN&gt; &lt;SPAN class="n"&gt;MATERIALIZED&lt;/SPAN&gt; &lt;SPAN class="k"&gt;VIEW&lt;/SPAN&gt; &lt;SPAN class="ss"&gt;"DBA"&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="ss"&gt;"MyView"&lt;/SPAN&gt; &lt;SPAN class="k"&gt;in&lt;/SPAN&gt; &lt;SPAN class="k"&gt;system&lt;/SPAN&gt; &lt;SPAN class="k"&gt;as&lt;/SPAN&gt; 
&lt;SPAN class="k"&gt;select&lt;/SPAN&gt; &lt;SPAN class="o"&gt;*&lt;/SPAN&gt; &lt;SPAN class="k"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;X&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;paramtable&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;where&lt;/SPAN&gt; &lt;SPAN class="n"&gt;X&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="nb"&gt;date&lt;/SPAN&gt; &lt;SPAN class="o"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="n"&gt;paramtable&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;A_PARAM&lt;/SPAN&gt; &lt;SPAN class="k"&gt;and&lt;/SPAN&gt; &lt;SPAN class="n"&gt;paramtable&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;PK&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="mi"&gt;1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 02 May 2011 17:16:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840121#M4870964</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-02T17:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized view with Parameter?</title>
      <link>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840125#M4870968</link>
      <description>&lt;P&gt;Am I right that a (CREATE) VARIABLE won't do, either, as it is connection-specific by default, and that would be non-deterministic, too?&lt;/P&gt;
&lt;P&gt;(I'm asking as using such a variable would be a common way to parametrize a &lt;EM&gt;normal&lt;/EM&gt; view.)&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2011 03:29:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840125#M4870968</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-05-03T03:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized view with Parameter?</title>
      <link>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840126#M4870969</link>
      <description>&lt;P&gt;(That would better asked as a separate question...): No, materialized views were introduced in v10.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2013 14:50:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/materialized-view-with-parameter/qaa-p/13840126#M4870969</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2013-02-01T14:50:48Z</dc:date>
    </item>
  </channel>
</rss>

