sqlanywhere光标临时表

发布于 2025-01-30 10:28:40 字数 736 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文