对链接服务器的存储过程调用存在语法错误?
我有一台 Informix 机器,已配置为 SQL Server 中的链接服务器。
我可以远程发送查询并接收查询结果,
SELECT * FROM linkedServer.instanceName.database.myTable
但无法运行
linkedServer.instanceName.database.selectAllFromMYTABLE
存储过程。
我返回的错误消息是“[Informix][Informix ODBC Driver][Informix]发生语法错误。”这并没有多大帮助,只是它告诉我我的请求是以某种形式收到的...
有人可以告诉我通过 SQL Server 执行 Informix 存储过程的正确调用语法是什么吗?大概我搞砸了存储过程调用,因为可以验证存储过程在 Informix 服务器上运行良好。
编辑:添加我正在测试的存储过程的全文,以验证我没有在 Informix 中做一些愚蠢的事情,这会导致 SQL Server 执行出现连锁问题:
CREATE FUNCTION sp_testSP()
RETURNING char(20) as item_no
DEFINE item_no char(20);
FOREACH
SELECT table_name.item_code
INTO item_no
FROM table_name
WHERE table_name.item_code LIKE 'test%'
RETURN item_no WITH RESUME;
END FOREACH;
END FUNCTION
正如我所提到的,这似乎是在 RazorSQL 中工作得很好,我已经将其连接到 Informix,但也许看到这会唤起某人的记忆,因为某些原因 SQL Server 无法使用此返回方法...
I've got an Informix machine I've configured as a linked server in SQL Server.
I can remotely send, and receive the results of, a query for, say
SELECT * FROM linkedServer.instanceName.database.myTable
but can't run the
linkedServer.instanceName.database.selectAllFromMYTABLE
stored procedure.
The error message I'm getting returned is "[Informix][Informix ODBC Driver][Informix]A syntax error has occurred." which is not massively helpful, except that it tells me that my request was received in some form...
Could someone tell me what the correct calling syntax would be to execute an Informix stored procedure via SQL Server? Presumably I'm screwing up the stored procedure call, because the stored procedure can be verified to be working fine on the Informix server.
EDIT: Adding the full text of a stored procedure I am testing, in order to verify I'm not doing something stupid in Informix which is causing a knock-on problem with the SQL Server execution:
CREATE FUNCTION sp_testSP()
RETURNING char(20) as item_no
DEFINE item_no char(20);
FOREACH
SELECT table_name.item_code
INTO item_no
FROM table_name
WHERE table_name.item_code LIKE 'test%'
RETURN item_no WITH RESUME;
END FOREACH;
END FUNCTION
As I've mentioned, this appears to work fine in RazorSQL, which I have connected to Informix, but maybe seeing this will jog someone's memory with some reason why SQL Server can't work with this return method...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过使用
OpenQuery
?http://msdn.microsoft.com/en-us/library/ms188427.aspx
Have you tried using
OpenQuery
?http://msdn.microsoft.com/en-us/library/ms188427.aspx
在本机 Informix 中,您可能会这样写(大约):
我不太确定将实例名称放入其中的位置 - “linkedServer”对应于实例名称(按照我的思维方式)。最接近的方法是:
但是,这是通过本机 Informix 接口。如果您通过 SQL Server,则语法可能需要是调用过程的本机 SQL Server 语法。理论上,我相信,所使用的 API(ODBC 或其他)应该能够转换为本机 Informix 语法。
In native Informix, you would write (approximately):
I'm not sure quite where you'd fit an instance name into that - the 'linkedServer' corresponds to an instance name (to my way of thinking). The nearest approaches would be:
However, that is via the native Informix interfaces. If you go via SQL Server, then the syntax probably needs to be the native SQL Server syntax for invoking a procedure. In theory, I believe, the API used (ODBC or whatever) should be able to translate to the native Informix syntax.