 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Stored Procedure Error</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/stored-procedure-error/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/stored-procedure-error/</link>
	<description></description>
	<lastBuildDate>Wed, 22 May 2013 17:18:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: gunapat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/stored-procedure-error/#comment-38524</link>
		<dc:creator>gunapat</dc:creator>
		<pubDate>Fri, 17 Dec 2004 12:38:57 +0000</pubDate>
		<guid isPermaLink="false">#comment-38524</guid>
		<description><![CDATA[You can&#039;t use direct sql in the stored procedure. You need to declare a cursor for the sql statment, open and fetch the cursor to process the result set.

For Example, in the stored proc you need to the following to get the resutl set,
declare cur_name cursor with return for
  select statement ....;
open cur_name;

If you need to process individual rows then you need to fetch otherwise open cur_name will return the result set as you expected. 

Make sure in the create procedure it has a specification to return one result set.
 Create procedure proc_name()
  result sets 1
  language sql
p1:begin

end p1

Hope this helps.

Thanks
Guna





]]></description>
		<content:encoded><![CDATA[<p>You can&#8217;t use direct sql in the stored procedure. You need to declare a cursor for the sql statment, open and fetch the cursor to process the result set.</p>
<p>For Example, in the stored proc you need to the following to get the resutl set,<br />
declare cur_name cursor with return for<br />
  select statement &#8230;.;<br />
open cur_name;</p>
<p>If you need to process individual rows then you need to fetch otherwise open cur_name will return the result set as you expected. </p>
<p>Make sure in the create procedure it has a specification to return one result set.<br />
 Create procedure proc_name()<br />
  result sets 1<br />
  language sql<br />
p1:begin</p>
<p>end p1</p>
<p>Hope this helps.</p>
<p>Thanks<br />
Guna</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: growl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/stored-procedure-error/#comment-38525</link>
		<dc:creator>growl</dc:creator>
		<pubDate>Fri, 17 Dec 2004 12:16:23 +0000</pubDate>
		<guid isPermaLink="false">#comment-38525</guid>
		<description><![CDATA[It appears that you meant to remark a line and did not:

--- SELECT * FROM DIMS_General_Search WHERE userId = 1 order by documentName , generalSearchId FETCH FIRST 30 Rows Only;

]]></description>
		<content:encoded><![CDATA[<p>It appears that you meant to remark a line and did not:</p>
<p>&#8212; SELECT * FROM DIMS_General_Search WHERE userId = 1 order by documentName , generalSearchId FETCH FIRST 30 Rows Only;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: arwinner</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/stored-procedure-error/#comment-38526</link>
		<dc:creator>arwinner</dc:creator>
		<pubDate>Fri, 17 Dec 2004 08:11:18 +0000</pubDate>
		<guid isPermaLink="false">#comment-38526</guid>
		<description><![CDATA[The problem is that a SELECT statement all by itself in a Stored Procedure (SP) is meaningless and therefore not allowed.  DB2 does not know what you intend to do with the result set, i.e. there is no indication on your part whether you want to do some processing within the SP on the result set, or you wish to have the calling procedure/application receive the result set.  To do this you need to use a cursor.  If you want to process the result set in the SP you would use OPEN CURSOR, and FETCH in a loop, then CLOSE it.  If you want the result set returned to the caller, declare the cursor as such and then you OPEN it and leave it open for the caller to use.

Andy
]]></description>
		<content:encoded><![CDATA[<p>The problem is that a SELECT statement all by itself in a Stored Procedure (SP) is meaningless and therefore not allowed.  DB2 does not know what you intend to do with the result set, i.e. there is no indication on your part whether you want to do some processing within the SP on the result set, or you wish to have the calling procedure/application receive the result set.  To do this you need to use a cursor.  If you want to process the result set in the SP you would use OPEN CURSOR, and FETCH in a loop, then CLOSE it.  If you want the result set returned to the caller, declare the cursor as such and then you OPEN it and leave it open for the caller to use.</p>
<p>Andy</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/9 queries in 0.015 seconds using memcached
Object Caching 296/299 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-22 17:34:20 -->