我见过一个,但是……10g 包装到底是什么?
场景:我对包一无所知,除了它们包含的函数和过程都包装在一个漂亮的小礼物中。所以今天我收到了这个包裹(相当大),上面写着“这里,这个坏了,请修复它”。
我终于把它全部清理干净了,这让我想到了我的问题。
在包的整体视图中,它将被导出。
1)除了所有东西的集合之外,包还有其他用途吗?
2)要部署此包,您是否需要设置部署空间以拥有该包调用的所有视图/物化视图/和表?如果不是,我假设该包将无法执行。
3) 您能否对包进行编码,使其跳过无法执行的函数和过程,而不会崩溃?
4)当将一个在一个地方成功编译的包转移到另一个地方时,我还应该注意哪些事情?
Scenario: I know nothing about packages except that they contain functions and procedures all wrapped into a nice little present. So today I was given this package (rather large) with the instructions of "here, this is broken please fix it".
I finally cleaned it all up, which brings me to my questions.
In the overall view of a package, that is going to be exported.
1) Other than a collection of everything does a package serve any other purpose?
2) To deploy this package do you need to set up the deployment space to already have all of the views/materialized views/ and tables that the package called? If not I am assuming the package will fail to execute.
3) Can you code the package to skip functions and procedures it fails to execute on without bombing out?
4) When taking a package that successfully compiled in one place to another place what other things should I be aware of?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
1) 除了所有内容的集合之外,包还有其他用途吗?
除此之外,它还减少了当特定过程发生更改时重新编译依赖于该特定过程的其他过程的需要。
考虑一个(普通的,非包方面的)
过程 XYZ(a in number)
,它被许多其他过程调用。如果更改此过程,则需要重新编译所有其他过程,这可能会降低系统的可用性。另一方面,如果该过程在
package
中声明并在package body
中定义,并且该过程仅在主体中更改,(几乎)不会发生重新编译。2) 要部署此包,您是否需要设置部署空间以拥有该包调用的所有视图/物化视图/和表?如果不是,我假设该包将无法执行。
不,您可以安装
包主体
,而无需安装相关视图或表。然后,包体的状态将为INVALID
,并且包体的任何功能都无法使用。3)您能否对包进行编码以跳过它无法执行的函数和过程而不崩溃?
不确定,问题到底是什么。如果包体的状态为 INVALID,则无法执行任何代码,因此不会发生“轰炸”。
但是,如果由于逻辑原因(例如除以零)而发生轰炸,则您始终可以在其他人构建时诉诸
异常
。4)当将一个在一个地方成功编译的包转移到另一个地方时,我还应该注意哪些其他事情?
同样,不确定你在这里的意思。您能详细说明一下一个地方是什么吗?一个模式?一个例子?一个装置,一个公司......?
1) Other than a collection of everything does a package serve any other purpose?
Other than that, it reduces the need to recompile other procedures that are dependant on a specific procedure when the specific procedure is altered.
Consider an (ordinary, not package wise)
procedure XYZ(a in number)
that is called by many other procedures. If this procedure is altered, all the other procedures need to be recompiled which might reduce the availablity of the system.On the other hand, if the procedure is declared in a
package
and defined in apackage body
and the procedure is changed in the body only, (almost) no recompiling takes place.2) To deploy this package do you need to set up the deployment space to already have all of the views/materialized views/ and tables that the package called? If not I am assuming the package will fail to execute.
No, you can install a
package body
without the dependant views or tables in place. The state of the package body will then beINVALID
and no functionality of the package body can be used.3) Can you code the package to skip functions and procedures it fails to execute on without bombing out?
Not sure, what the question is exactly. If the state of the package body is INVALID, no code can be executed, hence no "bombing out" can happen.
However, if the bombing out occurs for a logical reason (such as a division by zero for example) you can always resort to the
exception when others then
construct.4) When taking a package that successfully compiled in one place to another place what other things should I be aware of?
Again, not sure what you mean here. Could you elaborate what one place is? A schema? An instance? An installation, a company....?
1) 嗯,你几乎可以将包想象为类似于类。它是相关方法的逻辑分组。它还允许您封装其他人不应使用的相关“帮助程序”方法。它们可以包含在包中并且只能通过成员方法访问。
2)为了成功部署一个包,是的,您必须拥有必要的表、视图等。如果没有,则不是包无法执行任何过程或功能的问题,而是无法正确部署。它将在数据字典中显示为未编译。
3)定义“炸弹”。如果存在成功部署包所需的对象,那么其他一切都是运行时错误 - 应该对其进行编码。想想异常处理。
4) 同样,包中引用的必要架构对象必须存在。如果不这样做,该包将无法编译,并将在数据字典中进行标记。
1) Well you can almost think of a package as being analogous to a class. Its a logical grouping of related methods. It also allows you to encapsulate related "helper" methods that should not be used by anyone else. They can be included in the package and only accessible by member methods.
2) In order to successfully deploy a package, yes, you must have the necessary tables, views, etc. If they are not, its not a matter of the package not being able to execute any procedures or functions, it will not deploy properly. It will show up in the data dictionary as not compiled.
3) Define "bomb out". If the necessary objects exist to successful deploy the package, then everything else is a run time error - things that should be coded for. Think exception handling.
4) Again, the necessary schema objects referenced in your package must exist. If they do not, the package will not compile and will be marked as such in the data dictionary.
除了上面其他有用的答案之外。
1)
包头还可以保存其范围不仅仅限于过程或函数的变量。
2)
如果您要移动包表/视图,如果它们位于同一数据库中并且新架构有权查看旧表,则可能不需要复制它们。或者是否可以使用包含数据的数据库的数据库链接。在某些数据库版本中,跨数据库链接使用 lob 可能会受到限制。另一个模式中的表需要引用{schema-name}.{table-name}。数据库链接由{table-name}@{database-link-name}指定。向另一个模式中的表授予权限需要显式完成,而不是通过角色 - 这就是 oracle
3 的方式。
如果您添加:
“当其他人为空时例外;”
作为过程中的倒数第二行(紧邻“end”之前),它可能会执行您想要的操作。
4)
包运行可能需要授予/权限/角色/序列以及可能的同义词和其他依赖的过程/函数包。实际上,原始模式中的任何对象都可以在包中引用,并且可能需要,或者可能需要对其进行授权。
In addition to the other helpful answers above.
1)
Package headers can also hold variables whose scope is not just to a proc or function.
2)
If you are moving the package tables/views may not have to be copied if they are in the same database and the new schema has permission to see the old tables. or if a database link can be used to the database that contains the data. In some database versions there may be limits on using lobs across a database link. Tables in another schema need to be referenced {schema-name}.{table-name}. A database link is specified by {table-name}@{database-link-name}. Granting permission to a table in another schema will need to be done explicitly not through a role - thats just how oracle is
3.
If you add:
"exception when others then null; "
as the 2nd last line in a proc (immediately before "end") it may do what you are after.
4)
Grants/permissions/roles/sequences and possibly synonyms and other dependent procs/functions packages may be needed for the package to run. Actually any object in the original schema may be referenced in the package and may be needed or a grant on it may be needed..