简体   繁体   English

存储过程调用链接服务器上的语法错误?

[英]Syntax error on stored procedure call to linked server?

I've got an Informix machine I've configured as a linked server in SQL Server. 我有一台Informix机器,该机器已配置为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." 我返回的错误消息是“ [Informix] [Informix ODBC驱动程序] [Informix]发生语法错误。” 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? 有人可以告诉我通过SQL Server执行Informix存储过程的正确调用语法是什么吗? Presumably I'm screwing up the stored procedure call, because the stored procedure can be verified to be working fine on the Informix server. 大概我正在搞砸存储过程的调用,因为可以验证存储过程在Informix服务器上是否可以正常工作。

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: 编辑:添加我正在测试的存储过程的全文,以验证我没有在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

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... 正如我已经提到的那样,这在我连接到Informix的RazorSQL中似乎可以很好地工作,但是也许看到它会由于某种原因而使某人的内存慢跑,原因是SQL Server无法使用此return方法...

Have you tried using OpenQuery ? 您是否尝试过使用OpenQuery

http://msdn.microsoft.com/en-us/library/ms188427.aspx http://msdn.microsoft.com/en-us/library/ms188427.aspx

In native Informix, you would write (approximately): 在本机Informix中,您将编写(大约):

EXECUTE PROCEDURE database@linkedServer:selectAllFromMYTABLE();

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). 我不确定您是否适合在其中放置实例名称-'linkedServer'对应于实例名称(按照我的想法)。 The nearest approaches would be: 最接近的方法是:

database@linkedServer:instancename.selectAllFromMyTABLE()
instancename@linkedServer:database.selectAllFromMyTABLE()

However, that is via the native Informix interfaces. 但是,这是通过本地Informix接口进行的。 If you go via SQL Server, then the syntax probably needs to be the native SQL Server syntax for invoking a procedure. 如果通过SQL Server,则语法可能需要是调用过程的本机SQL Server语法。 In theory, I believe, the API used (ODBC or whatever) should be able to translate to the native Informix syntax. 从理论上讲,我相信,所使用的API(ODBC或其他)应该能够转换为本地Informix语法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM