sqlanywhere光标临时表
IM试图使用光标处理行,并为每行写入值到临时表。如果我使用for for for myloop作为我的mycursor光标,则可以使用此功能...但是我想将光标使用如t-sql所记录下来,并且一旦我不注册我试图声明临时表的行,我就会得到一个隐秘错误消息:
无法执行语句。 第10行(WATCOM SQL)附近的“开始”的语法错误 SQLCODE = -131,ODBC 3状态=“ 42000” 第10行
也在“临时表”声明中的列定义中的“ AS”不是问题!如果删除其他行,则可以在没有任何问题的情况下运行所评论的三行。
有什么想法吗?
BEGIN
-- DECLARE LOCAL TEMPORARY TABLE tempTable (iValue AS INTEGER);
DECLARE @iValue INT;
DECLARE myCursor CURSOR FOR SELECT ItemValue FROM ListItems;
OPEN myCursor;
FETCH NEXT myCursor INTO @iValue;
WHILE (@@FETCH_STATUS = 0) BEGIN
FETCH NEXT myCursor INTO @iValue
END;
CLOSE myCursor;
DEALLOCATE myCursor;
-- SELECT iValue AS [Values] FROM tempTable;
-- DROP TABLE IF EXISTS tempTable;
END
谢谢
Im trying to process rows using CURSOR and write values for each row to a temporary table. This works if I use the FOR loop e. g. FOR myLoop AS myCursor CURSOR FOR ... but I want to use the cursor as documented for T-SQL and as soon as I uncomment the line where I try to declare the temporary table I get a cryptic error message:
Could not execute statement.
Syntax error near 'BEGIN' on line 10 (Watcom SQL)
SQLCODE=-131, ODBC 3 State="42000"
Line 10
Also the 'AS' in the column definition in the temp table declaration is not the problem! The three lines that are commented out can be run without any problem if the other lines are removed.
Any Ideas?
BEGIN
-- DECLARE LOCAL TEMPORARY TABLE tempTable (iValue AS INTEGER);
DECLARE @iValue INT;
DECLARE myCursor CURSOR FOR SELECT ItemValue FROM ListItems;
OPEN myCursor;
FETCH NEXT myCursor INTO @iValue;
WHILE (@@FETCH_STATUS = 0) BEGIN
FETCH NEXT myCursor INTO @iValue
END;
CLOSE myCursor;
DEALLOCATE myCursor;
-- SELECT iValue AS [Values] FROM tempTable;
-- DROP TABLE IF EXISTS tempTable;
END
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论