使用临时表的 Sybase 存储过程。创作问题

发布于 2024-10-09 17:34:05 字数 179 浏览 11 评论 0原文

我正在尝试创建一个引用临时表的 sybase 存储过程,但我不知道该临时表的定义。我可以查看 proc 并找出临时表的样子,然后首先手动创建它,但我面临着大约 1000 个 proc(它们引用各种临时表),并且此解决方案将非常乏味。

我一直在寻找更具战略性的方法,但到目前为止还没有成功。如果您能与我分享您的想法,我将不胜感激。

I am trying to create a sybase stored procedure which references a temp table, but I do not know the definition of this temp table. I could look at the proc and figure out what the temp table looks like and manually create it first, but I'm faced with approximately 1000 procs (which reference all sorts of temp tables) and this solution would be extremely tedious.

I've been looking for a more strategic approach but no luck so far. I'd appreciate it if you could share your thoughts with me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

○愚か者の日 2024-10-16 17:34:05

看来您可能不明白 #table 的全部要点是:

  1. 它是临时的

  2. 它仅存在于创建它的存储过程的上下文中

  3. 它是私有的

因此创建一个新的存储过程来“引用”另一个过程的#table并不是一个合理的尝试。 要么使用自己的#table编写一个完全独立的存储过程,或者更改原始存储过程,以便临时表存在于其上下文之外(见下文)。

您将必须跳过重重困难,以及不同版本的 Sybase 的不同困难,才能获取此类 #table 中的定义或数据。

  • 如果您可以捕捉到其中一个存储过程正在执行的时刻,并且您拥有sa权限,那么您当然可以通过SybaseCentral检查DDL或其他 DBA 工具。

如果您正在执行文档练习,那么除了检查存储过程代码之外别无选择;如果不这样做,您将错过隐藏在代码中的 #table 的重要方面。

对于打算共享的临时表(即存在于存储过程的上下文之外),而不是:
创建表#my_table ...
用途:
创建表 tempdb..my_table ...
并在编译过程之前外部执行任何过程。

It appears you may not understand that the whole point of a #table is that:

  1. it is temporary

  2. it exists only in the context of the stored proc that creates it

  3. it is private

Therefore creating a new stored proc to "reference" the #table of another proc, is not a reasonable thing to attempt. Either write a completely independent stored proc with its own #table, or change the original stored proc so that the temporary table exists outside its context (see below).

You will have to jump through hoops, and different hoops for different versions of Sybase, to get at either the definition or the data in such #tables.

  • If you can catch the moment when one of those stored procs is executing, and you have sa privilege, you can certainly examine the DDL via SybaseCentral or other DBA tool.

If you are performing a documentation exercise, then there is no alternative to examining the sproc code; if you do not, you will miss important aspects of the #table that is buried in the code.

For temporary tables that are intended to be shared (ie. exist outside the context of a stored proc), instead of:
CREATE TABLE #my_table ...
use:
CREATE TABLE tempdb..my_table ...
and execute that outside any proc, before compiling the procs.

谷夏 2024-10-16 17:34:05

我认为您可以从 tempdb systables 和 syscolumns 表中获取 #table 元数据。

请参阅 Rob Verschoor 关于 #table 的文章 http://www.sypron.nl/temptab.html名称和 tempdb 转储加载技巧。

I think you could get #table metadata from tempdb systables and syscolumns tables.

Look at Rob Verschoor's article http://www.sypron.nl/temptab.html about #table name and tempdb dump load trick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文