<?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>topic Re: PROC SQL implicit pass-through to Oracle in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-implicit-pass-through-to-Oracle/m-p/232599#M42403</link>
    <description>&lt;P&gt;Hi Scott,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would expect that your last SQL using &lt;EM&gt;change_end_date &lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;&lt;FONT color="#800000"&gt;"&amp;amp;datetime"&lt;/FONT&gt;&lt;/SPAN&gt;dt&lt;/EM&gt;&amp;nbsp;&amp;nbsp;will convert nicely into Oracle SQL and will execute fully in-database. As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/9411"&gt;@jakarman﻿&lt;/a&gt;&amp;nbsp;points out option "SASTRACE" will tell you what's going on behind the scene and how much of the SAS SQL gets converted and sent to Oracle for execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Defensive programming is&amp;nbsp;generally a&amp;nbsp;good thing BUT column "watch_list_name" is indexed;&amp;nbsp;by applying&amp;nbsp;an upcase() function on this column the index&amp;nbsp;can't get used.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;      where upcase(watch_list_name) = 'WCHK' and
            upcase(change_current_ind) = 'Y';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I believe for "watch_list_name" and "change_current_ind" the load process needs to ensure that the values get loaded all uppercase so that any subsequent query doesn't need to use upcase() functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Patrick&lt;/P&gt;</description>
    <pubDate>Sun, 01 Nov 2015 00:14:15 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2015-11-01T00:14:15Z</dc:date>
    <item>
      <title>PROC SQL implicit pass-through to Oracle</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-implicit-pass-through-to-Oracle/m-p/232556#M42399</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this code from a SAS-supplied solution macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  proc sql;
    update seg_kc.fsc_entity_watch_list_dim
      set change_end_date=dhms(input(put(&amp;amp;runasofdate,8.),yymmdd8.),00,00,00),
           change_current_ind = 'N'
      where upcase(watch_list_name) = 'WCHK' and
            upcase(change_current_ind) = 'Y' and
            entity_watch_list_number in
              (select entity_watch_list_number
                 from STG_WTCH.wl_wchk_delete_load);
  quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I've modified it to close out all records, not just those matching the sub-query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  proc sql;
    update seg_kc.fsc_entity_watch_list_dim
      set change_end_date=dhms(input(put(&amp;amp;runasofdate,8.),yymmdd8.),00,00,00),
           change_current_ind = 'N'
      where upcase(watch_list_name) = 'WCHK' and
            upcase(change_current_ind) = 'Y';
  quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, it is taking forever to run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've always been taught not to call a function for every record in the dataset/table if that function is in fact just returning a constant. &amp;nbsp;I was also hoping the below would make PROC SQL use implicit pass-through to Oracle:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   %* get runasofdate ;
   %fcf_get_runasofdate;
   %put;
   %put &amp;gt;&amp;gt;&amp;gt; RUNASOFDATE: &amp;amp;runasofdate;
   %put;
   
   %* convert to datetime - this will execute once, at compile time ;
   %let datetime=%sysfunc(putn(%sysfunc(inputn(&amp;amp;runasofdate,yymmdd8.)),date9.)):00:00:00;
   %put &amp;gt;&amp;gt;&amp;gt; DATETIME:  &amp;amp;datetime;
   
   proc sql noprint;
      update seg_kc.fsc_entity_watch_list_dim
         set 
            change_end_date = "&amp;amp;datetime"dt,
            change_current_ind = 'N'
         where 
            upcase(watch_list_name) in ('WCHK','WORLDCHECK')
            and
            upcase(change_current_ind) = 'Y'
      ;
   quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But this is still taking forever.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can convert this to explicit pass-through, which performs well, but there may be issues with that when crossing environments (DEV/TEST/PROD) - I'd have to investigate that further.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, is there a way convert the above code to implicit pass-through, or otherwise improve the query performance?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks...&lt;/P&gt;</description>
      <pubDate>Sat, 31 Oct 2015 08:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-implicit-pass-through-to-Oracle/m-p/232556#M42399</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2015-10-31T08:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL implicit pass-through to Oracle</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-implicit-pass-through-to-Oracle/m-p/232558#M42400</link>
      <description>&lt;P&gt;Scott, When implicit is wanted then:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1/ your first check should be on the used functions the must be available in the RDBMS&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#p0f64yzzxbsg8un1uwgstc6fivjd.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#p0f64yzzxbsg8un1uwgstc6fivjd.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2/ You could follow (obs=0) the SQL&amp;nbsp;translation often the SQL is tried behind curtains and when failing all data is copied to the sas-machine. The sqltrace option is a must for analyzing what is happening. A nice paper. &lt;A href="http://support.sas.com/resources/papers/proceedings13/072-2013.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings13/072-2013.pdf&lt;/A&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3/ dates / datatimes quotings sqlconstdatetime and sqlreduceput are eliminating those sas specifics before trying to convert it to Oracle Sql &amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/68053/HTML/default/viewer.htm#p12ohgh32ffm6un13s7l2d5p9c8y.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/sqlproc/68053/HTML/default/viewer.htm#p12ohgh32ffm6un13s7l2d5p9c8y.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The quotation in SQL is normally single quotes in ANSI SQL for constant values. SAS is using the double-quotes when allowing macro vars it can be nedessary to stick to those single ones. Thena use %nrstr(%')&amp;nbsp; for that single quote.&lt;/P&gt;&lt;P&gt;The Date-constant should be translated to ansi standards. &lt;A href="http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements003.htm#BABGIGCJ" target="_blank"&gt;http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements003.htm#BABGIGCJ&lt;/A&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;The usage of date/time conventions as of SAS habits can cause problems. I have seen several posts indicating the automatic translation (SAS/access) is failing.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4/ forcing dbmust&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#p005mmm6mnyvdtn10rxbytrcqjgo.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#p005mmm6mnyvdtn10rxbytrcqjgo.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Oct 2015 11:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-implicit-pass-through-to-Oracle/m-p/232558#M42400</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-10-31T11:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL implicit pass-through to Oracle</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-implicit-pass-through-to-Oracle/m-p/232599#M42403</link>
      <description>&lt;P&gt;Hi Scott,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would expect that your last SQL using &lt;EM&gt;change_end_date &lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;&lt;FONT color="#800000"&gt;"&amp;amp;datetime"&lt;/FONT&gt;&lt;/SPAN&gt;dt&lt;/EM&gt;&amp;nbsp;&amp;nbsp;will convert nicely into Oracle SQL and will execute fully in-database. As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/9411"&gt;@jakarman﻿&lt;/a&gt;&amp;nbsp;points out option "SASTRACE" will tell you what's going on behind the scene and how much of the SAS SQL gets converted and sent to Oracle for execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Defensive programming is&amp;nbsp;generally a&amp;nbsp;good thing BUT column "watch_list_name" is indexed;&amp;nbsp;by applying&amp;nbsp;an upcase() function on this column the index&amp;nbsp;can't get used.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;      where upcase(watch_list_name) = 'WCHK' and
            upcase(change_current_ind) = 'Y';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I believe for "watch_list_name" and "change_current_ind" the load process needs to ensure that the values get loaded all uppercase so that any subsequent query doesn't need to use upcase() functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Patrick&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 00:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-implicit-pass-through-to-Oracle/m-p/232599#M42403</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-01T00:14:15Z</dc:date>
    </item>
  </channel>
</rss>

