<?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: Oracle  cursor in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Oracle-cursor/m-p/13339#M1556</link>
    <description>1)  Wouldn't it make more sense to either run this from SQL Plus? or as a stored procedure?&lt;BR /&gt;
&lt;BR /&gt;
2)  You may be able to use the pass-through facility and execute statement.&lt;BR /&gt;
&lt;BR /&gt;
3)  Does your code have some typo's, because it doesn't look like it would work as intended to me.&lt;BR /&gt;
&lt;BR /&gt;
4)  It seems to me that if you want to use SAS and determine if there are orphaned customer id's and sales_rep id's, you could use proc sql directly with some set relations:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select something from somewhere&lt;BR /&gt;
  except corr&lt;BR /&gt;
  select something from somewhereelse;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Thu, 24 Apr 2008 19:33:06 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-04-24T19:33:06Z</dc:date>
    <item>
      <title>Oracle  cursor</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-cursor/m-p/13338#M1555</link>
      <description>I have a cursor that I would like to execute via proc sql in base SAS.  Is this possible?  &lt;BR /&gt;
&lt;BR /&gt;
here is my code:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
declare &lt;BR /&gt;
  v_cust_id      int;&lt;BR /&gt;
  v_sales_rep_id int;&lt;BR /&gt;
&lt;BR /&gt;
  cursor   orphan_cursor is&lt;BR /&gt;
  select   cust_id&lt;BR /&gt;
  from     DTF_SALES_ITS_recur_5&lt;BR /&gt;
  order by cust_id desc;&lt;BR /&gt;
&lt;BR /&gt;
  cursor   reps_cursor is&lt;BR /&gt;
  select   sales_rep_id &lt;BR /&gt;
  from     DTF_SALES_ITS_recur_reps2&lt;BR /&gt;
  order by rand_number;&lt;BR /&gt;
&lt;BR /&gt;
begin&lt;BR /&gt;
  open reps_cursor;&lt;BR /&gt;
  for orph_val in orphan_cursor&lt;BR /&gt;
  loop&lt;BR /&gt;
    fetch reps_cursor into v_sales_rep_id;&lt;BR /&gt;
      if reps_cursor%notfound then  &lt;BR /&gt;
        close reps_cursor;&lt;BR /&gt;
        open  reps_cursor;&lt;BR /&gt;
        fetch reps_cursor into v_sales_rep_id;&lt;BR /&gt;
      end if;         &lt;BR /&gt;
    v_cust_id := orph_val.cust_id;&lt;BR /&gt;
    INSERT into univ_assign_orphans VALUES (v_cust_id, v_sales_rep_id);&lt;BR /&gt;
  end loop;&lt;BR /&gt;
  close  reps_cursor; &lt;BR /&gt;
end;</description>
      <pubDate>Thu, 24 Apr 2008 19:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-cursor/m-p/13338#M1555</guid>
      <dc:creator>mrscher22</dc:creator>
      <dc:date>2008-04-24T19:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle  cursor</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-cursor/m-p/13339#M1556</link>
      <description>1)  Wouldn't it make more sense to either run this from SQL Plus? or as a stored procedure?&lt;BR /&gt;
&lt;BR /&gt;
2)  You may be able to use the pass-through facility and execute statement.&lt;BR /&gt;
&lt;BR /&gt;
3)  Does your code have some typo's, because it doesn't look like it would work as intended to me.&lt;BR /&gt;
&lt;BR /&gt;
4)  It seems to me that if you want to use SAS and determine if there are orphaned customer id's and sales_rep id's, you could use proc sql directly with some set relations:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select something from somewhere&lt;BR /&gt;
  except corr&lt;BR /&gt;
  select something from somewhereelse;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 24 Apr 2008 19:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-cursor/m-p/13339#M1556</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-24T19:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle  cursor</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Oracle-cursor/m-p/13340#M1557</link>
      <description>Thanks for the reply, Chuck.&lt;BR /&gt;
&lt;BR /&gt;
I seems like your suggestion of using a stored proc is the right answer to my problem. The semi-colon in the code is the culprit even though it is in the passthrough statement, SAS parses the statement before passing it over to the dbms.</description>
      <pubDate>Fri, 25 Apr 2008 15:31:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Oracle-cursor/m-p/13340#M1557</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-25T15:31:45Z</dc:date>
    </item>
  </channel>
</rss>

