Desktop productivity for business analysts and programmers

Execute SQL Stored Procedure

Reply
Frequent Contributor
Posts: 131

Execute SQL Stored Procedure

[ Edited ]

Hi All,

 

Can anyone help me with the syntax to execute a simple stored procedure within an EG process flow?

I've seen a guide here - https://amadeus.co.uk/sas-tips/executing-sql-stored-procedures-using-proc-sql/ but would rather not include the log in details in the code.

 

I can run procsql using syntax like:

 

proc sql;
create table SqlserverLibrary.table as
select * from desktop1.all;
quit;

 

But I can't seem to execute a simple stored procedure in the same way. There are no parameters, the procedure simply drops some temp tables and recreates them with updated versions.

 

Any help appreciated

Super User
Posts: 5,917

Re: Execute SQL Stored Procedure

Posted in reply to itchyeyeballs

You need to do it in an explicit SQL pass through, by using either select * from connection to...() or execute () by...

There have been several posts about this on the communities, your should be able to find it by doing a serach.

Data never sleeps
Frequent Contributor
Posts: 131

Re: Execute SQL Stored Procedure

Thank  you,

 

I always try searching before posting but didn't spot anything useful, guess I wasn't using right terms so will give it another go using your hints.

 

I've gotten it working now using :

 

PROC SQL;
	Connect to odbc (datasrc=dbdsn user = user password = password);
		Execute(db.stored_proc) by odbc;
	Disconnect from odbc;
QUIT;

but I really don't like having the username and password in plain text

 

however I've managed to find

proc pwencode

which gets around the issue

 

(I'd still prefer to use the server authentication as I do when connecting to a library though)

New User
Posts: 1

Re: Execute SQL Stored Procedure

Posted in reply to itchyeyeballs

I am using the below code to execute a stored procedur but for the chanegs to show in the databse dont i need to commit them? if so can you do that from SAS?


proc sql;
connect to oracle (user='username' password=password path="path" );
execute (stored_proc) by oracle;
disconnect from oracle;
quit;

Frequent Contributor
Posts: 131

Re: Execute SQL Stored Procedure

If your not using transactions you shouldn't need to commit (although may depend on settings)

 

Some info here - https://dba.stackexchange.com/questions/84769/commit-and-rollback-in-oracle-stored-procedure

 

 

 

 

Ask a Question
Discussion stats
  • 4 replies
  • 1170 views
  • 0 likes
  • 3 in conversation