从 cfstoredproc 访问 RAISEERROR 消息
我有一个 SQL 存储过程,在某些情况下,如果失败,它会返回 -1 的结果,但也会通过 RAISERROR 命令返回一条消息,例如:
BEGIN
RAISERROR ('Error %i has occurred', 11, 1, 0)
RETURN -1
END
我使用 cfstoredproc 通过 Coldfusion 访问它,例如:
<cfstoredproc procedure="sp_return" datasource="myDatasource" returncode="yes">
<cfdump var="#cfstoredproc#">
但返回的结构仅包含 ExecutionTime和 StatusCode 键。有什么方法可以访问已返回的错误消息。例如显示给用户。
,
汤姆
谢谢 我会用“cfstoredproc”标记,但无法创建新标记。
I have a SQL stored procedure which under some situations will return a result of -1 if it fails, but also returns a message via the RAISERROR command e.g.:
BEGIN
RAISERROR ('Error %i has occurred', 11, 1, 0)
RETURN -1
END
I am accessing this via coldfusion using cfstoredproc e.g.:
<cfstoredproc procedure="sp_return" datasource="myDatasource" returncode="yes">
<cfdump var="#cfstoredproc#">
But the structure returned only contains an ExecutionTime and StatusCode keys. Is there any way I can access the error message which has been returned. e.g. To display to the user.
Thanks,
Tom
p.s. I would tag with "cfstoredproc" but I can't create new tags.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定您使用什么数据库,但对于 Oracle,我只是使用 ColdFusion 异常来冒泡 Oracle 异常。 - #cfcatch.message# 和 #cfcatch.detail# 是您想要向用户回显的内容。
Not sure what DB you use but with Oracle I just use ColdFusion Exceptions to bubble up the Oracle exceptions. - #cfcatch.message# and #cfcatch.detail# are what you want to echo to the user.
您尝试过cfprocresult吗? 手册页说:
Have you tried cfprocresult? Manual page says: