无法将 ORDER BY 命令添加到存储过程
我正在将我维护的某些软件中的存储过程从 SQL Server SQL 转换为 Informix SQL,但问题很多。
基本上我会逐行转换每个部分,直到转换整个内容。
我有以下 CREATE PROCEDURE
:
CREATE PROCEDURE ifxdbase:dc_buildSP (WorkID INT, CompNo smallint)
CREATE TEMP TABLE Items
(
Code smallint,
Qty int,
Total int
);
INSERT INTO Items
SELECT
tblDetails.code,
tblDetails.quantity,
tblHead.quantity
FROM
tblHead
INNER JOIN tblDetails ON (tblDetails.compno = tblDetails.compno AND tblDetails.id_num = tblHead.id_num)
WHERE tblHead.compno = CompNo AND tblHead.id_num = WorkID;
--ORDER BY tblDetails.code;
DROP TABLE Items;
END PROCEDURE
就目前情况而言,这工作正常,但是当我取消注释行 --ORDER BY tblDetails.seqno;
(并从上一行)我收到“-201 发生语法错误”错误。
基本上,tblHead
是一系列订单标题,tblDetails
是每个订单详细信息的表格。选择和加入数据工作正常,尝试对其进行排序失败。
排序应该适用于原始 SELECT、IIRC 中的任何内容,因此我看不出可能会出现什么问题,在这里......
I'm converting a stored procedure in some software I'm maintaining from SQL Server SQL to Informix SQL, and problems are abundant.
Basically I'm converting each section line-by-line until I have the whole thing converted.
I have the following CREATE PROCEDURE
:
CREATE PROCEDURE ifxdbase:dc_buildSP (WorkID INT, CompNo smallint)
CREATE TEMP TABLE Items
(
Code smallint,
Qty int,
Total int
);
INSERT INTO Items
SELECT
tblDetails.code,
tblDetails.quantity,
tblHead.quantity
FROM
tblHead
INNER JOIN tblDetails ON (tblDetails.compno = tblDetails.compno AND tblDetails.id_num = tblHead.id_num)
WHERE tblHead.compno = CompNo AND tblHead.id_num = WorkID;
--ORDER BY tblDetails.code;
DROP TABLE Items;
END PROCEDURE
As it stands, this works fine, but when I uncomment the line --ORDER BY tblDetails.seqno;
(and remove the semicolon from the previous line) I get a "-201 A syntax error has occurred" error.
Basically tblHead
is a series of order headers and tblDetails
is a table of the details of each of those orders. Selecting and joining the data works fine, trying to order it fails.
Ordering should work with anything from the original SELECT, IIRC, so I can't see what could be going wrong, here...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如此处:
因此 Informix 中的 INSERT 命令不支持 ORDER BY。
我现在没有要测试的东西,但你可以尝试这样的方法作为解决方法:
As stated here:
so ORDER BY is not supported in the INSERT command in Informix.
I don't have something to test right now, but you could try something like this, as a workaround: