我正在尝试编写一个存储过程,它通过连接传递的参数来动态工作。
CREATE OR REPLACE PROCEDURE E_Enquiry
(IN SourceQueue1 VARCHAR(30),
IN PayloadMsgId1 VARCHAR(100),
IN EventSource1 VARCHAR(100)
)
DYNAMIC RESULT SETS 1
LANGUAGE SQL
RETURNRT: BEGIN
DECLARE query_String VARCHAR(32000);
SET query_String = 'SELECT PayloadMsgId,ExceptionId,EventSource,E_Message.InterfaceId,CreationTime,SourceProtocol,ErrorMessage,Severity,InterfaceName
from E_Message,E_Config where' ;
if SourceQueue1 <> NULL THEN
SET query_String = query_String + 'SourceQueue='+SourceQueue1+'and';
end if;
if PayloadMsgId1 <> NULL THEN
SET query_String = query_String + 'PayloadMsgId='+PayloadMsgId1+'and';
end if;
if EventSource1 <> NULL THEN
SET query_String = query_String + 'EventSource='+EventSource1;
end if;
RETURNCR: BEGIN
DECLARE C1 CURSOR WITH RETURN TO CALLER FOR
query_String;
open C1;
END RETURNCR;
END RETURNRT
我不确定query_String是否在游标中调用时保存查询。此存储过程不返回任何值。有人可以帮助克服这个问题吗?