<?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 Calling a DB2 procedure has OUT parameter using SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Calling-a-DB2-procedure-has-OUT-parameter-using-SAS/m-p/69082#M19805</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
The book "SAS/ACCESS® 9.1.3 Supplement for DB2 under z/OS (SAS/ACCESS for Relational Databases" is mentioned as below to call a stored procedure which has out parameters&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
connect to db2;&lt;BR /&gt;
%let INOUT=2;&lt;BR /&gt;
create table sasresults as select * from connection to db2&lt;BR /&gt;
(call STORED_PROC (1,:INOUT,:OUT));&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
By referring the above sample I tried to call the stored procedure SASSP0004 but it throws an error as shown below&lt;BR /&gt;
&lt;BR /&gt;
148        proc sql;&lt;BR /&gt;
149        connect to db2(user=Iteration1 password=XXXXXXXXXX&lt;BR /&gt;
150              database=pbsdev);&lt;BR /&gt;
151        create table sasresults as select * from connection to db2&lt;BR /&gt;
152        (call SASSP0004(:SYS_OUT,0,2852700031)) ;&lt;BR /&gt;
ERROR: CLI prepare error: [IBM][CLI Driver][DB2/NT] SQL0312N  The host variable "SYS_OUT" is used in a dynamic SQL statement, a &lt;BR /&gt;
       view definition, or a trigger definition.  SQLSTATE=42618  &lt;BR /&gt;
SQL statement: call SASSP0004(:SYS_OUT,0,2852700031).&lt;BR /&gt;
&lt;BR /&gt;
Procedure Body:&lt;BR /&gt;
CREATE PROCEDURE SASSP0004 (&lt;BR /&gt;
    OUT SYS_OUT	varchar(5),&lt;BR /&gt;
    IN DELIVERY_ID_ST	DECIMAL(10,0),&lt;BR /&gt;
    IN DELIVERY_ID_EN	DECIMAL(10,0) )&lt;BR /&gt;
  LANGUAGE SQL &lt;BR /&gt;
 DYNAMIC RESULT SETS 1 &lt;BR /&gt;
BEGIN &lt;BR /&gt;
 DECLARE C1 CURSOR with return FOR SELECT * FROM db2table where delv_id between DELIVERY_ID_ST and DELIVERY_ID_EN; &lt;BR /&gt;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION&lt;BR /&gt;
  SELECT  'SYS' into  SYS_OUT  FROM SYSIBM.SYSDUMMY1;&lt;BR /&gt;
 OPEN C1; &lt;BR /&gt;
END;&lt;BR /&gt;
&lt;BR /&gt;
Kindly revert with the fix that should be done to the above PROC SQL code.</description>
    <pubDate>Wed, 14 Jan 2009 10:45:41 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-01-14T10:45:41Z</dc:date>
    <item>
      <title>Calling a DB2 procedure has OUT parameter using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calling-a-DB2-procedure-has-OUT-parameter-using-SAS/m-p/69082#M19805</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
The book "SAS/ACCESS® 9.1.3 Supplement for DB2 under z/OS (SAS/ACCESS for Relational Databases" is mentioned as below to call a stored procedure which has out parameters&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
connect to db2;&lt;BR /&gt;
%let INOUT=2;&lt;BR /&gt;
create table sasresults as select * from connection to db2&lt;BR /&gt;
(call STORED_PROC (1,:INOUT,:OUT));&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
By referring the above sample I tried to call the stored procedure SASSP0004 but it throws an error as shown below&lt;BR /&gt;
&lt;BR /&gt;
148        proc sql;&lt;BR /&gt;
149        connect to db2(user=Iteration1 password=XXXXXXXXXX&lt;BR /&gt;
150              database=pbsdev);&lt;BR /&gt;
151        create table sasresults as select * from connection to db2&lt;BR /&gt;
152        (call SASSP0004(:SYS_OUT,0,2852700031)) ;&lt;BR /&gt;
ERROR: CLI prepare error: [IBM][CLI Driver][DB2/NT] SQL0312N  The host variable "SYS_OUT" is used in a dynamic SQL statement, a &lt;BR /&gt;
       view definition, or a trigger definition.  SQLSTATE=42618  &lt;BR /&gt;
SQL statement: call SASSP0004(:SYS_OUT,0,2852700031).&lt;BR /&gt;
&lt;BR /&gt;
Procedure Body:&lt;BR /&gt;
CREATE PROCEDURE SASSP0004 (&lt;BR /&gt;
    OUT SYS_OUT	varchar(5),&lt;BR /&gt;
    IN DELIVERY_ID_ST	DECIMAL(10,0),&lt;BR /&gt;
    IN DELIVERY_ID_EN	DECIMAL(10,0) )&lt;BR /&gt;
  LANGUAGE SQL &lt;BR /&gt;
 DYNAMIC RESULT SETS 1 &lt;BR /&gt;
BEGIN &lt;BR /&gt;
 DECLARE C1 CURSOR with return FOR SELECT * FROM db2table where delv_id between DELIVERY_ID_ST and DELIVERY_ID_EN; &lt;BR /&gt;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION&lt;BR /&gt;
  SELECT  'SYS' into  SYS_OUT  FROM SYSIBM.SYSDUMMY1;&lt;BR /&gt;
 OPEN C1; &lt;BR /&gt;
END;&lt;BR /&gt;
&lt;BR /&gt;
Kindly revert with the fix that should be done to the above PROC SQL code.</description>
      <pubDate>Wed, 14 Jan 2009 10:45:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calling-a-DB2-procedure-has-OUT-parameter-using-SAS/m-p/69082#M19805</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-14T10:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a DB2 procedure has OUT parameter using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calling-a-DB2-procedure-has-OUT-parameter-using-SAS/m-p/69083#M19806</link>
      <description>Not sure if it applies to your problem specifically, but there is a SAS HOTFIX E9D213 which may address your error.  Also, the SAS support website  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  contains useful supplemental reference material and SAS-hosted DOCUMENTATION.  Using the SEARCH facility, I found a topic-related technical document (see link below) which also may be useful.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS/ACCESS® 9.1.x Interface to DB2 on the Mainframe&lt;BR /&gt;
Using the LIBNAME Engine&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/accessdb2.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/accessdb2.pdf&lt;/A&gt;</description>
      <pubDate>Wed, 14 Jan 2009 14:13:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calling-a-DB2-procedure-has-OUT-parameter-using-SAS/m-p/69083#M19806</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-01-14T14:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a DB2 procedure has OUT parameter using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calling-a-DB2-procedure-has-OUT-parameter-using-SAS/m-p/69084#M19807</link>
      <description>Thanks for your promptive response.&lt;BR /&gt;
&lt;BR /&gt;
Infact the doc that you enclosed in your post is mentioned as in the doc that I mentioned previously.&lt;BR /&gt;
&lt;BR /&gt;
I belive the above code works well in Z/OS environment&lt;BR /&gt;
&lt;BR /&gt;
Can anyone provide the sample PROC SQL code to call a DB2 procedure that has out parameter in windows environment?

Message was edited by: AnjiReddy1729</description>
      <pubDate>Thu, 15 Jan 2009 05:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calling-a-DB2-procedure-has-OUT-parameter-using-SAS/m-p/69084#M19807</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-15T05:21:39Z</dc:date>
    </item>
  </channel>
</rss>

