• <legend id='9i7gT'><style id='9i7gT'><dir id='9i7gT'><q id='9i7gT'></q></dir></style></legend>

      <bdo id='9i7gT'></bdo><ul id='9i7gT'></ul>

    <small id='9i7gT'></small><noframes id='9i7gT'>

        <i id='9i7gT'><tr id='9i7gT'><dt id='9i7gT'><q id='9i7gT'><span id='9i7gT'><b id='9i7gT'><form id='9i7gT'><ins id='9i7gT'></ins><ul id='9i7gT'></ul><sub id='9i7gT'></sub></form><legend id='9i7gT'></legend><bdo id='9i7gT'><pre id='9i7gT'><center id='9i7gT'></center></pre></bdo></b><th id='9i7gT'></th></span></q></dt></tr></i><div id='9i7gT'><tfoot id='9i7gT'></tfoot><dl id='9i7gT'><fieldset id='9i7gT'></fieldset></dl></div>

        <tfoot id='9i7gT'></tfoot>
      1. 存储过程 API 的最佳实践?

        时间:2023-08-20

      2. <small id='iScyU'></small><noframes id='iScyU'>

          <tbody id='iScyU'></tbody>
            <i id='iScyU'><tr id='iScyU'><dt id='iScyU'><q id='iScyU'><span id='iScyU'><b id='iScyU'><form id='iScyU'><ins id='iScyU'></ins><ul id='iScyU'></ul><sub id='iScyU'></sub></form><legend id='iScyU'></legend><bdo id='iScyU'><pre id='iScyU'><center id='iScyU'></center></pre></bdo></b><th id='iScyU'></th></span></q></dt></tr></i><div id='iScyU'><tfoot id='iScyU'></tfoot><dl id='iScyU'><fieldset id='iScyU'></fieldset></dl></div>
              • <bdo id='iScyU'></bdo><ul id='iScyU'></ul>

                <legend id='iScyU'><style id='iScyU'><dir id='iScyU'><q id='iScyU'></q></dir></style></legend>
                1. <tfoot id='iScyU'></tfoot>
                  本文介绍了存储过程 API 的最佳实践?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我们正在向我们的产品添加一些可由 3rd 方客户端调用的存储过程.是否有参数验证、返回值、RAISERROR 等的最佳实践?

                  We are adding some stored procedures to our product that can be called by 3rd-party clients. Are there best practices for parameter validation, return values, RAISERROR, etc?

                  第 3 方客户端不能直接访问表,只能访问某些 sproc.sprocs 接触的表受到了很好的约束,但我们希望尽可能方便用户,当 sprocs 被错误调用时提供详细的错误信息.

                  3rd-party clients will not have direct table access, only to certain sprocs. The table touched by the sprocs is well-constrained but we want to be as user-friendly as possible as far as providing detailed error information when the sprocs are called incorrectly.

                  推荐答案

                  提供人类可以理解的信息性错误消息并不难.只是带有描述性文本的 RAISERROR.稍微困难一点的是提高本地化文本,这意味着正确使用 sp_addmessage 和家人.真正的难题是引发程序可以做出反应的错误.这意味着正确记录错误代码(严重性状态),以及在 API 中使用它们的严格代码纪律.

                  Is not hard to provide informational error messages that a human can understand. Just RAISERROR with a descriptive text. slightly more difficult is to raise localized texts, which implies proper use of the sp_addmessage and family. The real hard problem is raising error to which a program can react. This means properly documented error codes (and severity and state), and severe code discipline in using them in your API.

                  并且不要忘记正确的事务嵌套.我的博客上有一个关于如何结合 T-SQL 异常正确处理事务的示例:异常处理和嵌套事务.

                  And don't forget proper transaction nesting. I have a sample on my blog on how to properly handle transactions in combination with T-SQL exceptions: Exception handling and nested transactions.

                  不幸的是,整个客户端/T-SQL 堆栈与异常相关的最新技术存在一些问题.最值得注意的是,如果您捕获 T-SQL 异常,则无法重新抛出它,因此您的客户端无法期待典型的系统错误号.请参阅 SQL Server:重新抛出异常与原始异常号码.这使您几乎没有办法传达正确的错误信息,除了在超过 50000 范围内使用您自己的错误编号之外,这非常麻烦,因为翻译"错误代码的数量增加了,并且使用错误消息字符串作为异常信息.

                  Unfortunately the state of the art on the whole client/T-SQL stack vis-a-vis exception has some problems. Most notable is that if you catch a T-SQL exception, you cannot rethrow it, so your client cannot expect the typical system error numbers. See SQL Server: Rethrow exception with the original exception number. This leaves you with little means to communicate proper error information, other than using your own error numbers on the over 50000 range, which is very cumbersome as the number of 'transalated' error codes increases, and using the error message string as the exception information.

                  这篇关于存储过程 API 的最佳实践?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:无法更新的 Sequelize 列 下一篇:在 SQLite C API 中使用 sqlite3_data_count() 而不是 sql

                  相关文章

                  最新文章

                    <i id='q8Jvc'><tr id='q8Jvc'><dt id='q8Jvc'><q id='q8Jvc'><span id='q8Jvc'><b id='q8Jvc'><form id='q8Jvc'><ins id='q8Jvc'></ins><ul id='q8Jvc'></ul><sub id='q8Jvc'></sub></form><legend id='q8Jvc'></legend><bdo id='q8Jvc'><pre id='q8Jvc'><center id='q8Jvc'></center></pre></bdo></b><th id='q8Jvc'></th></span></q></dt></tr></i><div id='q8Jvc'><tfoot id='q8Jvc'></tfoot><dl id='q8Jvc'><fieldset id='q8Jvc'></fieldset></dl></div>

                      <small id='q8Jvc'></small><noframes id='q8Jvc'>

                      <tfoot id='q8Jvc'></tfoot>

                        <bdo id='q8Jvc'></bdo><ul id='q8Jvc'></ul>

                    1. <legend id='q8Jvc'><style id='q8Jvc'><dir id='q8Jvc'><q id='q8Jvc'></q></dir></style></legend>