由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - SQL run a stored procedure by fetching from a cursor row by (转载)
相关主题
get value returned by SQLstored procedure from python再来一道简单的bit运算题
leetcode Nth Highest Salary 谁做出来了?google onsite杯具+设计题怎么答
请教个SQL的问题SEO题目
再请教SQL问题[新人]M家on campus interview面经
SQL find distinct values in large table (转载)新鲜夫家onsite面经
SQL interview questionCareercup question.
error of executing SQL query of string concatenation (转载编程菜鸟,请教CISCO面试题。
问一道老题VMWARE 的在线测试题一个
相关话题的讨论汇总
话题: fetch话题: cursor话题: declare话题: my话题: sql
进入JobHunting版参与讨论
1 (共1页)
l******9
发帖数: 579
1
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: SQL run a stored procedure by fetching from a cursor row by row
发信站: BBS 未名空间站 (Fri May 23 17:57:23 2014, 美东)
I need to run a stored procedure on SQL server 2008.
But, I can only fetch one row from the cursor. After that, the @@FETCH_
STATUS is -1.
DECLARE @my_table TABLE
(
code int not null
);
INSERT INTO @my_table (id)
SELECT DISTINCT a.id
FROM table1 as a
WHERE a.value = 'abc'
ORDER BY a.id ASC
DECLARE t_input CURSOR FOR
SELECT id
FROM @my_table
DECLARE @return_value tinyint
DECLARE @my_id varchar(3)
OPEN t_input
FETCH NEXT FROM t_input into @my_id
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC @return_value = my_procudure
@arg1 = 6,
@ar2 = 9
SELECT 'Return Value' = @return_value
FETCH NEXT FROM t_input into @my_id # this is -1 !!!!!!!!!!
END
So, it only run one iteration in the while loop.
my_procudure run well and has nothing to do with the cursor.
Any help would be appreciated.
1 (共1页)
进入JobHunting版参与讨论
相关主题
VMWARE 的在线测试题一个SQL find distinct values in large table (转载)
HTTP Error 403 (转载)SQL interview question
问个题error of executing SQL query of string concatenation (转载
一道sql问一道老题
get value returned by SQLstored procedure from python再来一道简单的bit运算题
leetcode Nth Highest Salary 谁做出来了?google onsite杯具+设计题怎么答
请教个SQL的问题SEO题目
再请教SQL问题[新人]M家on campus interview面经
相关话题的讨论汇总
话题: fetch话题: cursor话题: declare话题: my话题: sql