PL/SQL 中的事件驱动编程
我有两个 PL/SQL 系统,驻留在两个独立的数据库中。 SystemA 将需要填充SystemB 的表。这可能会通过数据链路完成。每次在 SystemB 的表中插入一组记录时,SystemB 中都必须运行一个进程。我可以等待 SystemA 完成,然后运行一个脚本来开始在 SystemB 中进行处理,但由于 SystemA 可能会花费很多时间处理然后填充 SystemB,所以我宁愿 SystemB 在每组记录可用后立即处理它们(每个集可以独立于其他集进行处理,因此这应该可以正常工作)。
我不确定如何在 PL/SQL 中进行偶数驱动编程。我需要 SystemA 通知 SystemB 一组已准备好处理。我的第一个想法是在 SystemB 中有一个特殊的“事件”表,然后当 SystemA 完成一组时,它会插入到“事件”表中,并且插入时有一个触发器启动该过程(并且该过程可能会很长) ,可能每个进程 5-10 分钟)在 SystemB 中。我对 Oracle 中的触发器没有足够的经验,不知道这是否是一种既定的方法,或者是否有更好的机制。建议?尖端?建议?
I have two PL/SQL systems, residing in two separate databases. SystemA will need to populate SystemB's tables. This will probably be done over a datalink. Everytime a set of records is inserted in SystemB's tables, a process in SystemB must run. I could wait for SystemA to complete and then run a script to start processing in SystemB, but since SystemA could spend many hours processing and then populating SystemB, I'd rather that SystemB handle each set of records as soon as they become available (each set can be processed indpendently of the others so this should work OK).
What I'm not sure of is how I can do even-driven programming in PL/SQL. I'd need SystemA to notify SystemB that a set is ready for processing. My first idea was to have a special "event" table in SystemB and then when SystemA finishes a set, it inserts into the "event" table and there is a trigger on insert that starts the process (and the process could be a long one, possibly 5-10 minutes per process) in SystemB. I don't have enough experience with triggers in Oracle to know if this is an established way of doing it, OR if there's a better mechanism. Suggestions? Tips? Advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 Oracle 高级队列;它就是为此而设计的。我相信您仍然需要在两个系统之间设置数据库链接(在本例中是从 B 到 A,以消耗 A 上的队列)。
Use Oracle Advanced Queuing; it's designed for this. I believe you'll still have to set up a database link between the two systems (from B to A in this case, to consume the queue on A).
是的,Oracle Advance Queues 甚至让 A 向 B 提交一个古老的 Oracle 作业将是一个更好的主意。
而且,如果您的流程需要将数据从 A 完整复制到 B,那么您可能需要使用类似于 Oracle Streams 流程的方式来复制数据,然后进行处理。
Yes, Oracle Advance Queues or even having A submit a venerable Oracle Job to B would be a better idea.
And, if your process is going to be needing complete replication of the data from A to B, then you might want to look something like an Oracle Streams process to copy over the data and then do the processing.