473,699 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.Net and DB2 triggers

hi Gurus,

Presently we have code that "polls" DB2 tables checking for new data.
A much more effective method, especially for real-time systems, would
be to call Dot Net code directly from within DB2 "on insert" or "on
update" triggers. I've not investigated this yet, but I suspect it is
possible. Does anybody know how this might be done?

thanks,
tom

Nov 12 '05 #1
3 1651
to*****@yahoo.c om wrote:
hi Gurus,

Presently we have code that "polls" DB2 tables checking for new data.
A much more effective method, especially for real-time systems, would
be to call Dot Net code directly from within DB2 "on insert" or "on
update" triggers. I've not investigated this yet, but I suspect it is
possible. Does anybody know how this might be done?

thanks,
tom

You can call a CLR Procedure or Function from an INSERT trigger.
Prereq is V8.2 when CLR support was added.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
Thank you very much - - Is it full of potential pitfalls, dangers, etc?
This is what I am hearing from a developer -
"Seems dangerous. I went to a talk on reliable code at the .NET
conference. The steps to make absolutely sure that all memory is
reclaimed and all resources are freed (even if you receive a thread
abort in the middle of a final statement) requires a deep understanding
of CLR and garbage collection. The talk was created because of the
ability in SQL 2005 to execute C# code within SQL server. To maintain
the '5' nines of up-time requires writing very safe code. Also, for
example, what would happen if a trigger on record insert required a hit
against a web service that happens to be timing out (let's say
30sec)? Would the record be available? Table be locked? Insert
statement throw an error? Etc."

Tom

Nov 12 '05 #3
to*****@yahoo.c om wrote:
Thank you very much - - Is it full of potential pitfalls, dangers, etc?
This is what I am hearing from a developer -
"Seems dangerous. I went to a talk on reliable code at the .NET
conference. The steps to make absolutely sure that all memory is
reclaimed and all resources are freed (even if you receive a thread
abort in the middle of a final statement) requires a deep understanding
of CLR and garbage collection. The talk was created because of the
ability in SQL 2005 to execute C# code within SQL server. To maintain
the '5' nines of up-time requires writing very safe code. Also, for
example, what would happen if a trigger on record insert required a hit
against a web service that happens to be timing out (let's say
30sec)? Would the record be available? Table be locked? Insert
statement throw an error? Etc."

Tom

Well I can't comment on SQL Server 2005 implementtion of course ;-)
In DB2 a CLR routine is FENCED. That is it runs in its own address
space. If the developer messes it up and kills it dead teh routine will
return a "Has been unexpectedly terminated" style SQLCODE/SQLSTATe. The
trigger will fail with a -723 (trigger failed with embedded said nasty
SQLCODE). A failing trigger means that teh statement will rollback.
None of that strikes me as out of the oridanry.
W.r.t. your webservice. I the CLR routine sits on its thumbs for 3 days
Db2 can't help it. If teh CLR routines hanldes teh timeout and returns
some reaasonable value or sqlcode then that will be fine.
All in all this is no different than what you woudl get calling a JAVA,
C, COBOL, FORTAN or SQL routine.
Business as usual...

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
6625
by: raulgz | last post by:
I need audit triggers that change columns value in the same record that fire trigger. I need how to do.. Thanks..
1
2093
by: jason_s_ford | last post by:
I have several sql server databases that were recently moved to a new server. In the process of migrating the databases, any triggers and constraints attached to tables were removed on accident. I need to add these objects back into the databases, however I'm worried that I will have problems with referential integrity since there is a chance someone may have deleted or updated a record that should have cascaded changes to other tables...
4
2532
by: Mark Flippin | last post by:
I'm just starting to use triggers in my databases and find the support in Enterpise Manager lacking. Using Enterprise Manager and Query Analyzer you can maintain the triggers, but it's cumbersome. Are there better tools for creating and managing triggers? Mark Flippin
1
1827
by: tim.pascoe | last post by:
I'm trying to generate scrips for a database, and everything so far has worked fine, except for the triggers. When I try and script existing triggers, all I get is a blank file - no SQL script. I tried single files for each object, all in one file, triggers only, the entire database. I can't figure it out, but I know the triggers are there. Any suggestions, or am I missing something undocumented in SQL-Server 2000?
4
2715
by: stacdab | last post by:
We have a partitioned view with 4 underlying tables. The view and each of the underlying tables are in seperate databases on the same server. Inserts and deletes on the view work fine. We then add insert and delete triggers to each of the underlying tables. The triggers modify a different set of tables in the same database as the view (different than the underlying table). The problem is those triggers aren't fired when inserting or...
5
2437
by: Bruce | last post by:
I have several user defined functions which are referenced in triggers and views. For software upgrades, I need to be able to drop the triggers and views which reference these user defined functions, then drop and recreate the user defined functions, then recreate all the views and triggers. I don't imiagine I'm the first person who needed to do this, and I don't have a lot of db2 experience, so I wanted to see if there is a common or...
0
4924
by: Bruno Lavoie | last post by:
Hello, i'm etablishing a naming convention for a new project under postgresql. For tables, sequences, views, that's ok! I used good naming conventions for this in the past and i'll keep these rules for the new project. but, i plan to use a lot of triggers and functions in this project, but I'm confused! I know that triggers call already created functions. But for tracking i must be able to associate these 2 different object
0
8321
debasisdas
by: debasisdas | last post by:
trigger sample code Ex#10 ======================= INSTEAD OF TRIGGER ---------------------------------------- create or replace trigger mytrig instead of delete or insert or update on eview declare a number(2); begin
0
4490
debasisdas
by: debasisdas | last post by:
This thread contains some useful tips/sample codes regarding TRIGGERS in oracle, that the forum members may find useful. TRIGGERS: =============== Database trigger is a PL/SQL block that is executed on an event in the database. The event is related to a particular data manipulation of a table such as inserting, deleting or updating a row of a table. Triggers may be used : 1.To implement complex business rule, which cannot be...
4
5742
by: --CELKO-- | last post by:
I need to convert a bunch of DB2 triggers to Oracle. Is there any kind of tools for this?
0
8686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9033
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7748
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.