Oracle触发器查询 [英] Oracle Triggers Query

查看:420
本文介绍了Oracle触发器查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们考虑一个表STUD,并在INSERT查询上实现一个行级TRIGGER.我的情况是这样的,每当插入一行时,都会触发一个触发器,并且它应该访问放在硬目录中的一些脚本文件.磁盘,最终应该打印结果.那么,这件事可能吗?如果是的话,那么这件事应该以动态形式存在,即,如果我们更改脚本文件的内容,那么oracle也应该反映这些更改.

Lets consider a Table STUD and a ROW-Level TRIGGER is implemented over INSERT query.. My scenario goes like this, whenever a row is inserted, a trigger is fired and it should access some script file which is placed in the hard disk, and ultimately should print the result. So, is this thing is possible? and if yes, then this thing should exist in dynamic form, i.e. if we change the content of script file, then the oracle should reflect those changes as well.

我尝试使用外部过程为Java执行此操作,但是对我想要的结果感到不满意.

I have tried doing this for java using External Procedures, but doesn't feel that much satisfied with the result that i wanted.

请就这种情况和实施方法提供您的观点.

Kindly give your point-of-view for this kind of scenario and ways that this can be implemented.

推荐答案

社区Wiki,这是一个不好的主意.

A community wiki for reasons why this is a bad idea.

为什么将文件用于动态代码变得愚蠢.

Reasons why using a file for dynamic code is dumb.

  1. 要插入的每一行都必须打开一个文件,读取所有内容,对其进行解析,然后对结果进行处理".那会很慢.

  1. Each row being inserted has to open a file, read the entire contents, parse it and 'do something' with the result. That is going to be SLOW.

取决于操作系统环境,您可能无法同时打开文件进行读写.因此,您可能会发现必须关闭数据库才能将代码更改促进"到文件中.

Depending on the OS environment, you may not be able to concurrently open the file for reading and writing. So you may find you have to shutdown the database to 'promote' code changes into the file.

根据操作系统的环境,您甚至可能一次只能读取一个会话.

Depending on the OS environment, you may even find that only one session can read from the file at a time.

也许触发器将在保存"过程中读取文件并执行部分代码.

Maybe the trigger will read the file in the middle of a 'save' and execute partial code.

文件安全性将与数据库安全性完全分开,从而造成维护麻烦.

File security will be totally separate from database security, creating a maintenance headache.

简而言之,将动态代码存储在表中而不是文件中将是一个巨大的改进.

In short, storing the dynamic code in a table, rather than a file, would be a MASSIVE improvement.

重新设置为什么不应该使用动态代码的原因:

Reasons why you shouldn't use dynamic code anyway:

  1. 动态代码尚未解析/编译.因此它可能无法正常工作,直到执行后您才能发现它.

  1. Dynamic code hasn't been parsed/compiled. So it may not work and you don't find out until it gets executed.

静态代码的性能优于动态代码,因为它们减少了解析开销.

Static code performs better than dynamic code because of reduced parsing overhead.

其他.原因

  1. 具有行级触发器读取并执行代码意味着,潜在地,将多条记录插入表中的同一条语句可能会选择不同版本的代码以针对不同的行插入执行.

这篇关于Oracle触发器查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆