在sql Developer中执行异步存储过程
我想使用 Oracle SQL Developer 多次异步执行存储过程。
伪代码
var pStatus number
var pOraErrCd varchar2
var pOraErrMsg varchar2
for i 1 .. 1000 -- do async
loop
exec myproc('test',:pStatus ,:pOraErrCd ,:pOraErrMsg);
end loop;
存储过程的目的是执行一些插入操作。为了测试,我只想多次异步执行存储过程。我不关心任何返回值。
有没有一种“简单”的方法来做到这一点?
I would like to use Oracle SQL Developer to execute a stored procedure asynchronously a large number of times.
Pseudo Code
var pStatus number
var pOraErrCd varchar2
var pOraErrMsg varchar2
for i 1 .. 1000 -- do async
loop
exec myproc('test',:pStatus ,:pOraErrCd ,:pOraErrMsg);
end loop;
The stored procedure's purpose is to do some inserts. For testing I just want to execute the stored procedure asynchronously a large number of times. I don't care about any return values.
Is there a "easy" way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您想要模拟 N 个会话,每个会话调用该过程 1000/N 次,因此我可能会这样做,
此示例将启动 10 个会话,每个会话将快速连续执行该过程 100 次,假设您的数据库的
JOB_QUEUE_PROCESSES
至少为 10,这意味着 Oracle 允许同时在后台运行 10 个作业。创建CALL_MYPROC_N_TIMES
过程并不是绝对必要的——它只是使构建要在作业中执行的字符串变得更容易。另一种方法是提交 1000 个作业,每个作业仅调用
MYPROC
一次,并依靠JOB_QUEUE_PROCESSES
参数来限制同时运行的作业数量。这可行,只是如果您想运行更多或更少的并发会话,则更改数据库参数会更加困难 - 在我发布的代码中调整L_NUM_SESSIONS
很容易。Since you want to simulate N sessions each calling the procedure 1000/N times, I would probably do something like
This example will start 10 sessions each of which will execute the procedure 100 times in quick succession assuming your database's
JOB_QUEUE_PROCESSES
is at least 10 meaning that Oracle is allowed to have 10 jobs running in the background simultaneously. Creating theCALL_MYPROC_N_TIMES
procedure isn't strictly necessary-- it just makes building the string to execute in the job easier.An alternative would be to submit 1000 jobs each of which just called
MYPROC
once and relying on theJOB_QUEUE_PROCESSES
parameter to limit the number of jobs that would be run simultaneously. That would work, it's just more difficult to change database parameters if you want to run more of fewer simultaneous sessions-- it's easy to adjustL_NUM_SESSIONS
in the code I posted.