DATA Step, Macro, Functions and more

Oracle cursor

Reply
N/A
Posts: 1

Oracle cursor

I have a cursor that I would like to execute via proc sql in base SAS. Is this possible?

here is my code:


declare
v_cust_id int;
v_sales_rep_id int;

cursor orphan_cursor is
select cust_id
from DTF_SALES_ITS_recur_5
order by cust_id desc;

cursor reps_cursor is
select sales_rep_id
from DTF_SALES_ITS_recur_reps2
order by rand_number;

begin
open reps_cursor;
for orph_val in orphan_cursor
loop
fetch reps_cursor into v_sales_rep_id;
if reps_cursor%notfound then
close reps_cursor;
open reps_cursor;
fetch reps_cursor into v_sales_rep_id;
end if;
v_cust_id := orph_val.cust_id;
INSERT into univ_assign_orphans VALUES (v_cust_id, v_sales_rep_id);
end loop;
close reps_cursor;
end;
N/A
Posts: 0

Re: Oracle cursor

1) Wouldn't it make more sense to either run this from SQL Plus? or as a stored procedure?

2) You may be able to use the pass-through facility and execute statement.

3) Does your code have some typo's, because it doesn't look like it would work as intended to me.

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:
[pre]
proc sql;
select something from somewhere
except corr
select something from somewhereelse;
quit;
[/pre]
N/A
Posts: 0

Re: Oracle cursor

Thanks for the reply, Chuck.

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.
Ask a Question
Discussion stats
  • 2 replies
  • 191 views
  • 0 likes
  • 2 in conversation