使用临时表的 Sybase 存储过程。创作问题
我正在尝试创建一个引用临时表的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来您可能不明白 #table 的全部要点是:
它是临时的
它仅存在于创建它的存储过程的上下文中
它是私有的
因此创建一个新的存储过程来“引用”另一个过程的#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:
it is temporary
it exists only in the context of the stored proc that creates it
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.
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.
我认为您可以从 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.