<?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: Problem with complex SQL in SAS SQL Pass through facility in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329026#M73550</link>
    <description>&lt;P&gt;see what info is provided in the saslog with the sastrace option.. as in the usage note at&amp;nbsp;&lt;A href="http://support.sas.com/kb/15/056.html" target="_blank"&gt;http://support.sas.com/kb/15/056.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Feb 2017 10:24:36 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2017-02-01T10:24:36Z</dc:date>
    <item>
      <title>Problem with complex SQL in SAS SQL Pass through facility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329009#M73547</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had problem using SAS SQL Passthrough facilities for PCFILES with DSN (ODBC) connection to Oracle database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My SAS environment only have "SAS/ACCESS for PC Files" and the "SAS PC File Server".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm manage to setup the oracle connection through SAS PC File Server --&amp;gt; DSN (ODBC)&amp;nbsp;--&amp;gt; Oracle Database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It only works if the SQL statement is simple or do not contain *. I had tested the same sql statements in oracle database and it ran just a few seconds.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Case 1: Simple Count = Works and SAS returned result in 1 seconds.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;connect to PCFILES (SERVER=localhost DSN=dsnname USER=typeuserhere PWD=typepasswordhere);&lt;BR /&gt;create table temp as&lt;BR /&gt;select * from connection to PCFILES&lt;BR /&gt;(&lt;FONT color="#0000FF"&gt;select &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;count(*) cnt&lt;/STRONG&gt;&lt;/FONT&gt; from&amp;nbsp;my_table&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;where rownum&amp;lt;10&lt;/FONT&gt;);&lt;BR /&gt;disconnect from PCFILES;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Case 2: With * = Not working, run indefinitely&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;proc sql;&amp;nbsp;&lt;BR /&gt;connect to PCFILES (SERVER=localhost DSN=&lt;SPAN&gt;dsnname &lt;/SPAN&gt;USER=typeuserhere PWD=typepasswordhere);&lt;BR /&gt;create table temp as&lt;BR /&gt;select * from connection to PCFILES&lt;BR /&gt;(&lt;FONT color="#0000FF"&gt;select &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;*&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;from&amp;nbsp;my_table&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;where rownum&amp;lt;10&lt;/FONT&gt;);&lt;BR /&gt;disconnect from PCFILES;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Case 3: complex oracle sql - few table joins, oracle functions etc. = Not Working, run indefinitely&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc sql;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;connect to &lt;/SPAN&gt;PCFILES&lt;SPAN&gt; (SERVER=&lt;/SPAN&gt;localhost DSN&lt;SPAN&gt;=dsnname &lt;/SPAN&gt;&lt;SPAN&gt;USER=&lt;/SPAN&gt;typeuserhere PWD&lt;SPAN&gt;=&lt;/SPAN&gt;typepasswordhere&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;create table temp as&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select * from connection to &lt;/SPAN&gt;PCFILES&lt;BR /&gt;&lt;SPAN&gt;(&lt;FONT color="#0000FF"&gt;with t as (&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;select '12345' cli from dual union all &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;select '67890' cli from dual union all &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;select '98765' cli from dual)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;select t.cli, max(pol.pol) keep (dense_rank last order by iss_dt) lst_pol,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;ca.addr_1, ca.addr_2, ca.addr_3, ca.addr_4, ca.zip_code, ca.country_cd&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;from t, cpl, pol, ca&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;where t.cli=cpl.cli&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;and cpl.pol=pol.pol&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;and in_force(pol.status)='Y'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;and cpl.cli=ca.cli&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;group by t.cli,ca.addr_1, ca.addr_2, ca.addr_3, ca.addr_4, ca.zip_code, ca.country_cd&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;disconnect from &lt;/SPAN&gt;PCFILES&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Font in blue color&lt;/STRONG&gt;=Passthrough SQL and suppose to process by Oracle.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if i amend the SQL and make some syntax error on purpose, i can get error returned by Oracle. It just doesnt work if everything is correct (i tested the same SQL by connect to Oracle directly).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Example of syntax error returned by SQL Passthrough:&amp;nbsp;ERROR: CLI describe error: [Oracle][ODBC][Ora]ORA-00904: "xxxxxx": invalid identifier&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the SQL seem to correctly processed by Oracle but it just hang somewhere.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;anyone facing this error or do you have any suggestion to solve this?&amp;nbsp;I'm not sure if this problem occur in SAS/ACCESS for Oracle... if yes, it defeat the purpose for me to request for purchase on&amp;nbsp;SAS/ACCESS for Oracle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 10:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329009#M73547</guid>
      <dc:creator>chinyong</dc:creator>
      <dc:date>2017-02-02T10:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with complex SQL in SAS SQL Pass through facility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329026#M73550</link>
      <description>&lt;P&gt;see what info is provided in the saslog with the sastrace option.. as in the usage note at&amp;nbsp;&lt;A href="http://support.sas.com/kb/15/056.html" target="_blank"&gt;http://support.sas.com/kb/15/056.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2017 10:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329026#M73550</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-02-01T10:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with complex SQL in SAS SQL Pass through facility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329030#M73552</link>
      <description>&lt;P&gt;thanks for suggestion. will try to look at it once i got chance later.&lt;BR /&gt;&lt;BR /&gt;hopefully able to find the root cause on the hanging issue.&lt;BR /&gt;&lt;BR /&gt;it just doesn't make sense that a sql take seconds to process by oracle took forever in SAS SQL passthough facility.&lt;BR /&gt;&lt;BR /&gt;but if i added any syntax error in any part of sql randomly, the error is returned as per it processed by oracle.&lt;BR /&gt;&lt;BR /&gt;the problem even more strange where i can pass a simple Oracle specific sql (non ANSI SQL) successfully through SAS sql passthough facility.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2017 13:05:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329030#M73552</guid>
      <dc:creator>chinyong</dc:creator>
      <dc:date>2017-02-01T13:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with complex SQL in SAS SQL Pass through facility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329058#M73563</link>
      <description>&lt;P&gt;SASTRACE is of little&amp;nbsp;use when it comes to explicit pass through. It's tailored for implicit&amp;nbsp;pass through. Which should be the primary choice. Explicit should only be used if critical&amp;nbsp;parts of the query isn't pass through automatically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, everything&amp;nbsp;with the parentheses&amp;nbsp;is the concern of the underlying RDBMS, you need to start your research&amp;nbsp;there, not in SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2017 12:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329058#M73563</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-02-01T12:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with complex SQL in SAS SQL Pass through facility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329066#M73565</link>
      <description>&lt;P&gt;thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;for pointing out the confusion I caused by combining 2 ideas without clarification.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For examining any implicit pass-thru problem, I'm sure &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;would agree that the SASTRACE options are the best way to go.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a quick sql solution that does not need the problems associated with implict &amp;nbsp;pass-thru, the explicit way might be worth trying separately.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2017 12:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329066#M73565</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-02-01T12:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with complex SQL in SAS SQL Pass through facility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329137#M73588</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;&amp;amp; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15174"&gt;@Peter_C&lt;/a&gt;!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried different odbc now and i think you are right. it seem like not related to SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;with &lt;STRONG&gt;Oracle ODBC Driver&lt;/STRONG&gt;:&amp;nbsp;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;- Only simple sql works.&lt;/P&gt;&lt;P&gt;- does't support complex sql and select * (hanging indefinitely).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;with &lt;STRONG&gt;Microsoft ODBC driver for Oracle&lt;/STRONG&gt;:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;- Most of the SQL works.&lt;/P&gt;&lt;P&gt;- except all SQL must start with "select" statement and cannot start with the Oracle's "With clause".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2nd solution works as long as I'm not using Oracle's "With Clause". I think i can survive without the "With Clause"&amp;nbsp;as it can be replaced with subquery anyway (with a little overhead).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;still curious why Oracle ODBC Driver doesn't work with SAS but Microsoft does.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 10:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-complex-SQL-in-SAS-SQL-Pass-through-facility/m-p/329137#M73588</guid>
      <dc:creator>chinyong</dc:creator>
      <dc:date>2017-02-02T10:44:16Z</dc:date>
    </item>
  </channel>
</rss>

