PL/SQL 上下文如何工作?
我对 PL/SQL 上下文有一些疑问,是否存在:
- PL/SQL 上下文是静态的?
- PL/SQL 上下文是同步的?
- 如果一个过程同时被调用两次,第一个过程需要 20 秒才能完成。第二个过程会等待这 20 秒才能开始执行吗?
谢谢。
i have some doubts about the PL/SQL context, are there:
- the PL/SQL context is static ?
- the PL/SQL context is sync ?
- if a procedure was called two times at the same time, the first one takes 20 seconds to complete.. will the second one wait this 20 seconds to start its execution ?
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每个引用包的数据库会话都有该包的独立实例。所有包状态(即全局包变量)对于每个会话都是不同的。
调用相同包过程或函数的多个会话之间不存在同步,除非它们执行的数据库操作以及实现这些操作所需的锁定可能产生自然副作用。
Each database session that references a package has an independent instance of the package. All package state (i.e. global package variables) is distinct to each session.
There is no synchronization between multiple sessions invoking the same package procedures or functions -- except what might occur as a natural side effect of the database operations that they perform and the locking required to achieve them.
你的问题有点难以理解。我会尝试以任何方式回答它。
PL/SQL 是一种过程语言。所以我不会谈论实例。代码仅存在一次,包变量在每个会话中存在一次,局部变量在每次调用过程或函数时存在一次。您无法访问其他会话的变量或内存。
对 PL/SQL 代码的所有调用都是同步的。没有诸如多线程或共享内存之类的概念(在 PL/SQL 中)。但请注意,Oracle 是一个多用户系统。因此其他会话可能会同时更改数据库中的数据。由于交易隔离,其中许多更改暂时对您隐藏。但它不会影响内存中的任何变量。
过程永远不会阻塞,除非它们尝试与另一个会话更改相同的数据库行。但这与任何 PL/SQL 代码无关,并且也可以通过从不同工具运行的 SQL 命令来体验。
Your questions are a bit difficult to understand. I'll try to answer it any way.
PL/SQL is a procedural language. So I wouldn't talk about instances. The code only exists once, the package variables exist once per session and the local variables exist once per call of the procedure or function. You cannot access aonther session's variables or memory.
All calls to PL/SQL code are synchronuous. There are no concepts like multi-threading or shared memory (in PL/SQL). Note however, that Oracle is a multi-user system. So other sessions might be changing data in the database at the same time. And many of these changes a temporarily hidden from you due to transaction isloation. But it doesn't influence any variables in memory.
Procedures never block unless they try to change the same database row as another session. But this isn't related to any piece of PL/SQL code and can also be experienced with an SQL command run from a different tool.