13.07.2015 Views

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>SAS</strong>/<strong>ACCESS</strong> Interface to DB2 Under z/OS 4 Examples 495The simplest way to call a stored procedure is to use the EXECUTE statement inPROC SQL. In this example, STORED_PROC is executed using a CALL statement.<strong>SAS</strong> does not capture the result set.proc sql;connect to db2;execute (call "schema".stored_proc);quit;Stored Procedure That Returns a Result SetYou can also return the result set to a <strong>SAS</strong> table. In this example, STORED_PROC isexecuted using a CALL statement. The result is returned to a <strong>SAS</strong> table, SasResults.proc sql;connect to db2;create table sasresults as select * from connection to db2 (call "schema".stored_proc);quit;Stored Procedure That Passes ParametersThe CALL statement syntax supports the passing of parameters. You can specifyinput parameters as numeric constants, character constants, or a null value. You canalso pass input parameters by using <strong>SAS</strong> macro variable references. To capture thevalue of an output parameter, a <strong>SAS</strong> macro variable reference is required. Thisexample uses a constant (1), an input/output parameter (:INOUT), and an outputparameter (:OUT). Not only is the result set returned to the <strong>SAS</strong> results table, the <strong>SAS</strong>macro variables INOUT and OUT capture the parameter outputs.proc sql;connect to db2;%let INOUT=2;create table sasresults as select * from connection to db2(call "schema".stored_proc (1,:INOUT,:OUT));quit;Stored Procedure That Passes NULL ParameterIn these calls, NULL is passed as the parameter to the DB2 stored procedure.Null string literals in the callcall proc(’’);call proc("")Literal period or literal NULL in the callcall proc(.)call proc(NULL)<strong>SAS</strong> macro variable set to NULL string%let charparm=;call proc(:charparm)<strong>SAS</strong> macro variable set to period (<strong>SAS</strong> numeric value is missing)%let numparm=.;call proc(:numparm)Only the literal period and the literal NULL work generically <strong>for</strong> both DB2 characterparameters and DB2 numeric parameters. For example, a DB2 numeric parameter

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!