<?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: Calling Oracle User-Defined Functions in SAS EG in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-Oracle-User-Defined-Functions-in-SAS-EG/m-p/749162#M38959</link>
    <description>&lt;P&gt;If you use the query builder then SAS generates SAS SQL flavor code. During execution time SAS will attempt to translate this code to the DB flavor code and send as much of the logic as it can to the database for execution.&amp;nbsp; SAS doesn't "know" that function &lt;SPAN&gt;F_CALC_REGISTRATION_HOURS() is an Oracle UDF and though won't send it to the database for execution - but then because the function doesn't exist on the SAS side your code will fail.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What you need is explicit SQL which instructs SAS to send all of your code "as is" to the database for execution.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Using the query builder you could try "&lt;STRONG&gt;Generate source for explicit pass-through&lt;/STRONG&gt;" - this might or might not work (see &lt;A href="https://support.sas.com/kb/60/884.html" target="_self"&gt;SAS Note&lt;/A&gt; here). But even if it doesn't work it still should generate the code pattern for you.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Code like below should work.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  connect to oracle as ora (&amp;lt;connection string&amp;gt;);
  select * from connection to ora
    (
      SELECT
        TBRACCD_PIDM
        ,TBRACCD_TERM_CODE
        ,BANINST1.F_CALC_REGISTRATION_HOURS(TBRACCD_PIDM,TBRACCD_TERM_CODE, 'TOTAL', 'CREDIT') AS Total_Credit_Hours
      FROM TBRACCD
        WHERE TBRACCD_BALANCE != 0
          AND TBRACCD_TERM_CODE NOT IN ('ARTERM')
    );
  disconnect from ora;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;If you've got already a valid libname to the Oracle schema defined then you can also use the libref in the connect statement as below (documented &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0rn6hhsizv3trn1cl3e0ofosawi.htm" target="_self"&gt;here&lt;/A&gt;).&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  connect using &amp;lt;SAS libref&amp;gt; as ora;
  select * from connection to ora
    (
      SELECT
        TBRACCD_PIDM
        ,TBRACCD_TERM_CODE
        ,BANINST1.F_CALC_REGISTRATION_HOURS(TBRACCD_PIDM,TBRACCD_TERM_CODE, 'TOTAL', 'CREDIT') AS Total_Credit_Hours
      FROM TBRACCD
        WHERE TBRACCD_BALANCE != 0
          AND TBRACCD_TERM_CODE NOT IN ('ARTERM')
    );
  disconnect from ora;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 20 Jun 2021 20:52:56 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-06-20T20:52:56Z</dc:date>
    <item>
      <title>Calling Oracle User-Defined Functions in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-Oracle-User-Defined-Functions-in-SAS-EG/m-p/749095#M38957</link>
      <description>&lt;P&gt;I want to call an Oracle user-defined function within SAS EG. The function is to be called as a column output from a table and uses parameters from the said table as well. I tried to do it as a computed column but SAS EG said it wasn't a valid. I would normally call the function from SQL as follows:&lt;/P&gt;
&lt;P&gt;SELECT&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;TBRACCD_PIDM&lt;/FONT&gt;&lt;BR /&gt;,&lt;FONT color="#339966"&gt;TBRACCD_TERM_CODE&lt;/FONT&gt;&lt;BR /&gt;,BANINST1.F_CALC_REGISTRATION_HOURS(&lt;FONT color="#0000FF"&gt;TBRACCD_PIDM&lt;/FONT&gt;,&lt;FONT color="#339966"&gt;TBRACCD_TERM_CODE&lt;/FONT&gt;, 'TOTAL', 'CREDIT') AS Total_Credit_Hours&lt;BR /&gt;FROM TBRACCD&lt;BR /&gt;WHERE TBRACCD_BALANCE != 0&lt;BR /&gt;AND TBRACCD_TERM_CODE NOT IN ('ARTERM')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I pulled in&amp;nbsp;TBRACCD from my library and used Query Builder to select the columns I want as output and add the necessary filters but just can't get the function call in. Is it possible from SAS EG?&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jun 2021 11:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-Oracle-User-Defined-Functions-in-SAS-EG/m-p/749095#M38957</guid>
      <dc:creator>dobby</dc:creator>
      <dc:date>2021-06-20T11:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Oracle User-Defined Functions in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-Oracle-User-Defined-Functions-in-SAS-EG/m-p/749158#M38958</link>
      <description>&lt;P&gt;Try using SAS code. The EG Query Builder will only go so far with database-specific features.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try adding your query into something similar to this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myora oracle datasrc=datasource schema = schema user=user password = password;

proc sql;
 connect using myora;
  create table Want as 
  select * from connection to myora
  (&amp;lt;-Put your Oracle query here-&amp;gt;)
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Jun 2021 20:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-Oracle-User-Defined-Functions-in-SAS-EG/m-p/749158#M38958</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-06-20T20:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Oracle User-Defined Functions in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-Oracle-User-Defined-Functions-in-SAS-EG/m-p/749162#M38959</link>
      <description>&lt;P&gt;If you use the query builder then SAS generates SAS SQL flavor code. During execution time SAS will attempt to translate this code to the DB flavor code and send as much of the logic as it can to the database for execution.&amp;nbsp; SAS doesn't "know" that function &lt;SPAN&gt;F_CALC_REGISTRATION_HOURS() is an Oracle UDF and though won't send it to the database for execution - but then because the function doesn't exist on the SAS side your code will fail.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What you need is explicit SQL which instructs SAS to send all of your code "as is" to the database for execution.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Using the query builder you could try "&lt;STRONG&gt;Generate source for explicit pass-through&lt;/STRONG&gt;" - this might or might not work (see &lt;A href="https://support.sas.com/kb/60/884.html" target="_self"&gt;SAS Note&lt;/A&gt; here). But even if it doesn't work it still should generate the code pattern for you.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Code like below should work.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  connect to oracle as ora (&amp;lt;connection string&amp;gt;);
  select * from connection to ora
    (
      SELECT
        TBRACCD_PIDM
        ,TBRACCD_TERM_CODE
        ,BANINST1.F_CALC_REGISTRATION_HOURS(TBRACCD_PIDM,TBRACCD_TERM_CODE, 'TOTAL', 'CREDIT') AS Total_Credit_Hours
      FROM TBRACCD
        WHERE TBRACCD_BALANCE != 0
          AND TBRACCD_TERM_CODE NOT IN ('ARTERM')
    );
  disconnect from ora;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;If you've got already a valid libname to the Oracle schema defined then you can also use the libref in the connect statement as below (documented &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0rn6hhsizv3trn1cl3e0ofosawi.htm" target="_self"&gt;here&lt;/A&gt;).&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  connect using &amp;lt;SAS libref&amp;gt; as ora;
  select * from connection to ora
    (
      SELECT
        TBRACCD_PIDM
        ,TBRACCD_TERM_CODE
        ,BANINST1.F_CALC_REGISTRATION_HOURS(TBRACCD_PIDM,TBRACCD_TERM_CODE, 'TOTAL', 'CREDIT') AS Total_Credit_Hours
      FROM TBRACCD
        WHERE TBRACCD_BALANCE != 0
          AND TBRACCD_TERM_CODE NOT IN ('ARTERM')
    );
  disconnect from ora;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jun 2021 20:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-Oracle-User-Defined-Functions-in-SAS-EG/m-p/749162#M38959</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-06-20T20:52:56Z</dc:date>
    </item>
  </channel>
</rss>

