Triggers compuestos – DBA Experts

Triggers compuestos – DBA Experts

En algunas ocasiones necesitamos realizar disparadores (Triggers) en tablas, pero la lógica del negocio nos obliga a realizar consulta en la misma tabla en la que se realizará el trigger u operaciones de agrupación, como count, sum, etc.

Si intentamos realizar esto con un trigger de la forma tradicional, tendremos que en el momento de ejecutar la instrucción DML (Data Manipulation Language), el disparador nos retornará un error de «Tabla Mutante» (ORA-04091).

Para evitar este error y facilitar el uso de los Triggers, Oracle ha implementado, a partir de la versión 11 g, el uso de los «COMPOUND TRIGGER» (Disparadores compuestos).

La estructura de estos es muy fácil, ya que te permiten tener hasta 4 bloques de código para realizar la operación que necesites. Los bloques Antes y despues de la instrucción DML (Before – After statement) y los bloques antes y después de cada registro (Before – After each row).

Combinando estos bloques puedes realizar cualquier operación que necesites con los triggers, teniendo en cuenta que sólo en los bloques EACH ROW puedes tener acceso a las variables :NEW y :OLD, aunque puedes crear variables globales dentro del Trigger y utilizarlo en caulquier bloque.

 

La sintaxis es bastante simple, aquí un ejemplo:

Ten en cuenta que cuando realizas DML masivo, como un update de varios registros al mismo tiempo, el código de los bloques «before statement» y «after statement» se ejecutará una única vez y los bloques «before each row» y «after each row» se ejecutará por cada registro que afecte la instrucción DML.

Esta entrada tiene 63 comentarios

  1. An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!

  2. I just want to tell you that I’m new to blogs and certainly liked your web blog. Almost certainly I’m likely to bookmark your site . You really come with remarkable stories. Thanks a bunch for revealing your blog.

  3. Hello.. . I would be grateful for advice on creative writing copywright issues.. . When submitting poetry, short stories, novels, or features to publishers and literary agents to consider for publication, is it an idea to protect the copywright?. . If so, what’s the best way to do this?. . Thank you in advance.. . bgscotty.

  4. i require some concepts for a blog. i currently do rhymes as well as studies on it however i wan na talk about something.

  5. What is the most effective way to search for blog sites you are interested in?

  6. DnJPh0 Just Browsing While I was surfing today I noticed a excellent article concerning

  7. What is the most effective software application to develop websites and also blog sites?

  8. I wanted to thank you for this abundant read!! I absolutely enjoyed each little crumb of it. I have got you bookmarked to ensure made known original stuff you post

  9. Merely wanna say that this is very helpful , Thanks for taking your time to write this.

  10. There as definately a great deal to know about this subject. I like all the points you have made.

  11. Really informative blog article.Much thanks again. Really Cool.

  12. internet. You actually know how to bring an issue to light and make it important.

  13. Wow! This could be one particular of the most helpful blogs We ave ever arrive across on this subject. Actually Excellent. I am also an expert in this topic so I can understand your effort.

  14. I view something really special in this site.

  15. Hi, i have a free wordpress blog site. I have actually included the widgets that come in the widget area. But how do i include widgets that are from 3rd parties such as clustrmaps? If cost-free wordpress blogs don’t allow that, which cost-free blog service allows that?.

  16. Well I really liked studying it. This subject offered by you is very effective for proper planning.

  17. ??? ????? ?????? ??? ????????, ?? ??? ????? ???? ?????? ?? ????? ???? ??????? ??? ??????? ??? ?????? ?????? ??? ?? ???? ????? .

  18. I value the article post.Much thanks again. Fantastic.

  19. It’s unique to find an expert through whom you would have several trustworthiness. On this planet with the current economic week, none of us realistically cares about presenting others the result in such an subjecttopic. Precisely how fortuitous I’m sure having clearly spotted actually outstanding blog because. It’s individuals like you whom develop serious difference nowadays over the ideas which they explain.

  20. lyon casino view of Three Gorges | Wonder Travel Blog

  21. This web page may be a walk-through like the data you wanted concerning this and didn’t know who need to. Glimpse here, and you’ll certainly discover it.

  22. Thanks so much for the blog article.Really looking forward to read more. Really Cool.

  23. Very good info. Lucky me I came across your website by accident (stumbleupon). I have book-marked it for later!

  24. I truly like your weblog put up. Keep publishing far more valuable details, we value it!

  25. Utterly composed articles , Really enjoyed examining.

  26. Read this Article Good info and right to the point. I am not sure if this is really the best place to ask but do you people have any thoughts on where to employ some professional writers? Thank you 🙂

  27. Your style is so unique in comparison to other people I ave read stuff from. Many thanks for posting when you have the opportunity, Guess I all just bookmark this web site.

  28. I like your website.. great shades & motif. Performed people design and style this fabulous website yourself or even have people rely on someone else to make it work for you personally? Plz interact when I!|m looking to pattern by myself blog site plus would want to find out wherever u received this particular through. thank you

  29. I value the post.Much thanks again. Awesome.

  30. Thanks for sharing, this is a fantastic blog.Really thank you! Great.

  31. I’m happy! It’s pleasant to see someone really educated about what they do. Hold up the excellent perform and I’ll return for additional! Many thanks!

  32. Every code I try either leaves a substantial space on top of the page, or at the bottom of the web page. Its absolutely that code creating it. I have actually tried many codes trying to hide the blog sites & extensive network, however they all leave a white void either at the top or near the bottom. Any individual got one that does not trigger the white space? Or how to eliminate the white gap?.

  33. Stunning story there. What occurred after? Take care!

  34. I?ve recently started a website, the information you provide on this site has helped me tremendously. Thank you for all of your time & work.

  35. Wow, fantastic blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your website is fantastic, as well as the content!

  36. Tumblr article I saw someone writing about this on Tumblr and it linked to

  37. Usa Online Casinos view of Three Gorges | Wonder Travel Blog

  38. What as up it as me, I am also visiting this web site on a regular basis, this website is genuinely

  39. Ita??a?аАа’аАТ‚аЂ s really a nice and useful piece of information. Ia??a?аАа’аАТ‚аЂ m satisfied that you shared this helpful info with us. Please stay us informed like this. Thank you for sharing.

  40. You have brought up a very excellent points , thanks for the post. Wit is educated insolence. by Aristotle.

  41. You made some decent points there. I looked on the internet for the issue and found most guys will consent with your blog.

  42. Right now it appears like BlogEngine is the preferred blogging platform out there right now. (from what I ave read) Is that what you are using on your blog?

  43. link:Stunning pictures of the beutiful Krita Sanon with music Luka Chuppi Duniyaa coca cola tu luka chuppi

  44. What blog site websites would certainly benefit a small business in floral and presents?

  45. I am looking both for blog sites that offer unbiased, balanced commentary on all issues or blog sites that have a liberal or left-wing slant. Thank you.

  46. If you want to increase your knowledge only keep visiting this website and be updated with the hottest information posted here.

  47. Excellent weblog right here! Also your website loads up very fast! What web host are you the usage of? Can I am getting your associate hyperlink for your host? I desire my web site loaded up as quickly as yours lol

  48. Fantastic post but I was wanting to know if you could write a litte more on this topic? I’d be very thankful if you could elaborate a little bit further.Thanks!

  49. Hi friends, its wonderful piece of writing about tutoringand completely defined, keep it up all the time.

  50. Very good article! We are linking to this particularly great content on our website.Keep up the great writing.

  51. Nice read, I just passed this onto a colleague who was doing a little research on that. And he just bought me lunch as I found it for him smile So let me rephrase that: Thanks for lunch!

  52. I think other web-site proprietors should take this website as an model, very clean and excellent user friendly style and design, as well as the content. You’re an expert in this topic!

Deja un comentario

cerrar