Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2013
    Posts
    11

    Unanswered: Java method invocation from DB2 trigger

    Can anybody please direct me to any link on the web, which has an example of how a java UDF can be invoked from a db2 update trigger? I need to pass the New/old reference to the method and also the table name.

    thanks in advance.

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    How would you do it if the UDF was SQL and not Java?

    Andy

  3. #3
    Join Date
    Apr 2013
    Posts
    11
    Hi Andy, SQL would also work for us. But it might be pretty complicated. So wanted to explore the java option.

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Keep in mind that java routines run slower than SQL routines.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  5. #5
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Changing it to SQL was not my original point. It was that it does not matter how the UDF is implemented (Java, SQL, etc), you would invoke it the same way.

    But Marcus is correct. If you can write it in SQL, then you should. Save Java for things you cannot do with SQL.

    Andy

  6. #6
    Join Date
    Apr 2013
    Posts
    11
    Ok. To elaborate a bit further, I am writing an update trigger and want to pass the reference to the new_row/old_row and the table name to a java method that returns string. What would be the signature of the java method in that case?

  7. #7
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Quote Originally Posted by rearden View Post
    Ok. To elaborate a bit further, I am writing an update trigger and want to pass the reference to the new_row/old_row and the table name to a java method that returns string. What would be the signature of the java method in that case?
    The UDF will not work no matter what it is written in. The references to the old row, and new row are only valid within the trigger. They have no scope beyond the trigger.

    Andy

  8. #8
    Join Date
    Apr 2013
    Posts
    11
    Thanks for the prompt replies guys. That helped.

  9. #9
    Join Date
    Apr 2013
    Posts
    11
    Does DB2 support java UDF with varargs?

  10. #10
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Quote Originally Posted by rearden View Post
    Does DB2 support java UDF with varargs?
    No. How would you define it do DB2?

    How about using XML for the parameter?

    Andy

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •