<?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: How To call functions from oracle database wintin SAS in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630882#M20874</link>
    <description>&lt;P&gt;This is not a stored proc but a function; so do we need a from ??? I'm confused. I pasted the full code from functions tab in Oracle.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Mar 2020 12:24:34 GMT</pubDate>
    <dc:creator>Anju</dc:creator>
    <dc:date>2020-03-10T12:24:34Z</dc:date>
    <item>
      <title>How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630778#M20853</link>
      <description>&lt;P&gt;I'm trying to call a function called schema.function_name using pass thru similar to calling a Stored procedure which I've done before. But this isn't working. What is the right syntax to call functions within sas ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CONNECT TO oracle (user=xxx&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;password=xxx&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;path=xxx);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;exec&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(EXECUTE schema.table ('schema.function_name')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;) by oracle;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DISCONNECT FROM oracle;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 00:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630778#M20853</guid>
      <dc:creator>Anju</dc:creator>
      <dc:date>2020-03-10T00:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630783#M20855</link>
      <description>&lt;P&gt;Isn't a function normally returning a value and though you'd use it in a Select statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd first get the Oracle SQL working using an editor like SQL Developer, DBeaver ..... and only when working wrap SAS code around.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 01:16:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630783#M20855</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-10T01:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630784#M20856</link>
      <description>&lt;P&gt;Hello Patrick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes it works fine in SQL developer and it will return a value of 'Y' or 'N'. Are you saying I can use in a select statement. Can you help me with the syntax pls ? Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 01:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630784#M20856</guid>
      <dc:creator>Anju</dc:creator>
      <dc:date>2020-03-10T01:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630785#M20857</link>
      <description>&lt;P&gt;Can you post your working Oracle SQL so I better understand what you have.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just on a "conceptual" level something along the line of below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  connect to oracle (...);
  select * from connection to Oracle 
    (
      select schema.function_name(&amp;lt;parameter&amp;gt;) as result
      from dual
    );
  disconnect from oracle;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Mar 2020 01:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630785#M20857</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-10T01:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630786#M20858</link>
      <description>&lt;P&gt;If it returns something try running it via SELECT instead of EXECUTE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
CONNECT TO oracle ...;
select * from connection to oracle
(EXECUTE schema.table ('schema.function_name')
);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sometime you have to wrap procedure calls in Oracle into a block.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
CONNECT TO oracle ...;
execute by oracle
(begin EXECUTE schema.table ('schema.function_name') end
);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Mar 2020 01:31:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630786#M20858</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-10T01:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630871#M20867</link>
      <description>&lt;P&gt;CREATE OR REPLACE FUNCTION xxx(p_limit NUMBER DEFAULT 1000000,p_min_pop_id NUMBER DEFAULT NULL,p_max_pop_id NUMBER DEFAULT NULL) RETURN CHAR AS&lt;BR /&gt;l_min_pop_id NUMBER;&lt;BR /&gt;l_max_pop_id NUMBER;&lt;BR /&gt;l_cnter NUMBER := 0;&lt;BR /&gt;l_next_pop_id NUMBER;&lt;/P&gt;&lt;P&gt;BEGIN&lt;BR /&gt;IF p_min_pop_id IS NOT NULL AND p_max_pop_id IS NOT NULL THEN&lt;BR /&gt;l_min_pop_id := p_min_pop_id ;&lt;BR /&gt;l_max_pop_id := p_max_pop_id ;&lt;BR /&gt;ELSE&lt;BR /&gt;SELECT min(mdm_pop_id) min_pop_id,max(mdm_pop_id) max_pop_id&lt;BR /&gt;INTO l_min_pop_id ,l_max_pop_id&lt;BR /&gt;FROM mdm.mdm_pop_tt&lt;BR /&gt;WHERE mdm_valid_to_dttm is not null;&lt;BR /&gt;END IF;&lt;/P&gt;&lt;P&gt;l_next_pop_id := l_min_pop_id;&lt;BR /&gt;WHILE l_next_pop_id &amp;lt;= l_max_pop_id LOOP&lt;BR /&gt;l_cnter := l_cnter + 1;&lt;/P&gt;&lt;P&gt;INSERT INTO mdm.mdm_pop_tt_history&lt;BR /&gt;SELECT tt.*,SYSDATE FROM mdm.mdm_pop_tt tt&lt;BR /&gt;WHERE tt.mdm_pop_id BETWEEN l_next_pop_id AND (l_next_pop_id + p_limit) AND tt.mdm_valid_to_dttm IS NOT NULL;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DELETE FROM mdm.mdm_pop_tt tt&lt;BR /&gt;WHERE tt.mdm_pop_id BETWEEN l_next_pop_id AND (l_next_pop_id + p_limit) AND tt.mdm_valid_to_dttm IS NOT NULL;&lt;BR /&gt;--dbms_output.put_line(l_cnter || '- Iteration :-' || l_next_pop_id || '-' || (l_next_pop_id + p_limit));&lt;/P&gt;&lt;P&gt;COMMIT;&lt;/P&gt;&lt;P&gt;l_next_pop_id:= l_next_pop_id + p_limit + 1;&lt;/P&gt;&lt;P&gt;END LOOP;&lt;BR /&gt;DBMS_STATS.gather_table_stats(ownname =&amp;gt; 'MDM',tabname =&amp;gt; 'MDM_pop_TT',estimate_percent =&amp;gt; DBMS_STATS.AUTO_SAMPLE_SIZE,method_opt =&amp;gt; 'for all indexed columns', cascade =&amp;gt; true);&lt;BR /&gt;DBMS_STATS.gather_table_stats(ownname =&amp;gt; 'MDM',tabname =&amp;gt; 'MDM_pop_TT_HISTORY',estimate_percent =&amp;gt; DBMS_STATS.AUTO_SAMPLE_SIZE,method_opt =&amp;gt; 'for all indexed columns', cascade =&amp;gt; true);&lt;BR /&gt;RETURN 'Y';&lt;BR /&gt;EXCEPTION&lt;BR /&gt;WHEN OTHERS THEN&lt;BR /&gt;--dbms_output.put_line(l_cnter || 'ERROR:-' || SQLCODE || '- ' || SQLERRM);&lt;BR /&gt;RETURN 'N';&lt;BR /&gt;END;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 11:51:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630871#M20867</guid>
      <dc:creator>Anju</dc:creator>
      <dc:date>2020-03-10T11:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630872#M20868</link>
      <description>&lt;P&gt;Here is the code which perfectly works in sql developer and I still can't get to call this function into sas&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 11:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630872#M20868</guid>
      <dc:creator>Anju</dc:creator>
      <dc:date>2020-03-10T11:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630879#M20873</link>
      <description>&lt;P&gt;Hard to read that since you pasted it as if it was your comments. Make sure to use the INSERT CODE button in the forum editor when inserting code or data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It does not look to me that you showed how you are CALLING that function.&amp;nbsp; Just the definition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since it returns a character value I would assume you need to call it with something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select xxx(...) as results from dual;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In which case to do that from SAS just wrap the Oracle select inside a SAS select.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from connection to oracle
(select xxx(...) as results from dual)
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Mar 2020 12:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630879#M20873</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-10T12:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630882#M20874</link>
      <description>&lt;P&gt;This is not a stored proc but a function; so do we need a from ??? I'm confused. I pasted the full code from functions tab in Oracle.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 12:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630882#M20874</guid>
      <dc:creator>Anju</dc:creator>
      <dc:date>2020-03-10T12:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630893#M20879</link>
      <description>&lt;P&gt;This is my recent try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;CONNECT TO oracle (user=xxx&lt;BR /&gt;password=xxx&lt;BR /&gt;path=xxx);&lt;BR /&gt;create table test as&lt;BR /&gt;select * from connection to oracle&lt;BR /&gt;(execute schema.xxx)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;DISCONNECT FROM oracle;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: ORACLE prepare error: ORA-24333: zero iteration count. SQL statement: execute schema.xxx&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 13:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630893#M20879</guid>
      <dc:creator>Anju</dc:creator>
      <dc:date>2020-03-10T13:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630921#M20881</link>
      <description>&lt;P&gt;This query worked for me:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;CONNECT TO oracle ...;&lt;BR /&gt;create table job204 as&lt;BR /&gt;select * from connection to oracle&lt;BR /&gt;(select xxx from dual);&lt;/P&gt;&lt;P&gt;DISCONNECT FROM ORACLE;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;where xxx is the name of the function which was defined in oracle&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 13:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/630921#M20881</guid>
      <dc:creator>Anju</dc:creator>
      <dc:date>2020-03-10T13:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/631172#M20887</link>
      <description>&lt;P&gt;Does that mean you've got your solution and this question is answered? If so then please mark the contribution which helped you most as solution.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 08:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/631172#M20887</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-11T08:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/631219#M20893</link>
      <description>&lt;P&gt;Not fully. The code I pasted is able to read the functions and it comes with an output 'N'. It is not executing the code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 13:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/631219#M20893</guid>
      <dc:creator>Anju</dc:creator>
      <dc:date>2020-03-11T13:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/749085#M29551</link>
      <description />
      <pubDate>Sun, 20 Jun 2021 11:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/749085#M29551</guid>
      <dc:creator>dobby</dc:creator>
      <dc:date>2021-06-20T11:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/749092#M29552</link>
      <description>&lt;P&gt;Please don't piggy-back on other peoples questions but ask a new question. Eventually add a link to the old question if you want to reference it.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jun 2021 11:42:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/749092#M29552</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-06-20T11:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: How To call functions from oracle database wintin SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/749094#M29553</link>
      <description>&lt;P&gt;Noted. Thank you.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jun 2021 11:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-To-call-functions-from-oracle-database-wintin-SAS/m-p/749094#M29553</guid>
      <dc:creator>dobby</dc:creator>
      <dc:date>2021-06-20T11:54:23Z</dc:date>
    </item>
  </channel>
</rss>

