If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > UDFs and Triggers Atomic nature

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-20-09, 09:09
fabyos fabyos is offline
Registered User
 
Join Date: May 2009
Posts: 2
UDFs and Triggers Atomic nature

Hi,

I'm new with DB2, I came from SQL Server so there is some kind of things that is really different.

I'm using DB2 8.2 on Windows.

I've to create an UDF that is called by a trigger, but this kind of implementation lock some dependencies. I cant fix my UDF because its being used by my trigger... or UDFs that use this function..

I think this is because of the BEGIN ATOMIC that cant be removed on a UDF/Trigger, at least when you need declare local variables...

Am I doing something wrong, or this is the implementation of DB2, I can understand why this happen but this turn the maintenance difficult to do, if necessary.

I tried to read a lot of references/redbooks/books about UDFs and stored procedures... but none gets deep on this topic...

Thanks for any help.
Reply With Quote
  #2 (permalink)  
Old 05-20-09, 09:26
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
It is not because you have BEGIN ATOMIC in your UDF. There are objects that are dependent (references) your UDF. In order to "fix" (maintain/change) your UDF, you have to DROP it first the CREATE it the new way. But with the dependencies, you cannot drop it. You will need to drop the dependent objects (triggers, other UDFs, etc) first, then DROP your UDF. Then you recreate your "fixed" UDF and then all the objects you dropped that are dependent on it.

Andy
Reply With Quote
  #3 (permalink)  
Old 05-20-09, 13:14
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
An alternative is to use external UDFs written in C or Java. There, you can replace the implementation without having to drop the dependent objects as long as the CREATE FUNCTION statement itself doesn't have to be changed.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 05-20-09, 13:25
fabyos fabyos is offline
Registered User
 
Join Date: May 2009
Posts: 2
Thanks for all responses..

@Andy

Yeah, this is the way that I'm doing stuffs... this is much work but it confirmed my thoughts..

@Stolze

Thanks for the reference.. I'll give a look to external UDFs... using external doesnt lock the compiled code in Java or C?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On