By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,554 Members | 1,084 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,554 IT Pros & Developers. It's quick & easy.

Can i write a user defined function in db2 Universal8.2 by the java or other language?

P: n/a
Hello all,
I want to write a user defined function in the bd2 database
that will return somethings from database by the java like srote
procedure. Is it possible, if yes Please give me hints.

...Mamun

Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
In article <11**********************@f14g2000cwb.googlegroups .com>,
Ma*******@gmail.com says...
Hello all,
I want to write a user defined function in the bd2 database
that will return somethings from database by the java like srote
procedure. Is it possible, if yes Please give me hints.

..Mamun


Read the docs at http://tinyurl.com/9bmxk
Nov 12 '05 #2

P: n/a
The short answer is Yes. You can find it in the manuals.

The right answer is not to do this; stick with the SQL/PSM which was
meant for use with SQL and is not kludged into it. SQL is a
set-oriented language while 3GL and OO languages are record-oriented.
We do not like functions, which do not work on an entire table all at
once, let a query, update or insert statement.

These languages have different rules about math and strings. They will
make maintaining the RDBMS a nightmare for the next guy who has to
learn 14 different programmign languages.

Nov 12 '05 #3

P: n/a
--CELKO-- wrote:
The short answer is Yes. You can find it in the manuals.

The right answer is not to do this; stick with the SQL/PSM which was
meant for use with SQL and is not kludged into it. SQL is a
set-oriented language while 3GL and OO languages are record-oriented.
We do not like functions, which do not work on an entire table all at
once, let a query, update or insert statement.

These languages have different rules about math and strings. They will
make maintaining the RDBMS a nightmare for the next guy who has to
learn 14 different programmign languages.

Joe,

I would agree with you for functions which modify SQL data.
But what is wrong about a so-called "parameterized view", I.e wrapping a
correlated query into a table function;
or scalar functions which do any sort of math.
Also note that SQL Functions in DB2 are SQL/PSM compliant.

Cheers
Serge

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

P: n/a
>> would agree with you for functions which modify SQL data. <<

How about CHECK() constraints that use user-defiend functions?
scalar functions which do any sort of math. <<
Back in the old days, I did a diagram in SQL FOR SMARTIES with all the
ways that MOD() worked in SQL products. They were different for
negative and non-integer numbers. Hell, Pascal implementations were
were different for negative and non-integer numbers!!
Also note that SQL Functions in DB2 are SQL/PSM compliant. <<


But other 3GLs do not.

Nov 12 '05 #5

P: n/a
--CELKO-- wrote:
would agree with you for functions which modify SQL data. <<

How about CHECK() constraints that use user-defiend functions? Only CONTAINS SQL or NO SQL, DETERMINISTIC and NO EXTERNAL ACTION.
E.e. it's safe. There is nothing that protects you against changing teh
implementation of an external UDF of course. But then again wrong
results are wrong results. A wrong UDf is no worse than a wrong
constraint or query.
scalar functions which do any sort of math. <<

Back in the old days, I did a diagram in SQL FOR SMARTIES with all the
ways that MOD() worked in SQL products. They were different for
negative and non-integer numbers. Hell, Pascal implementations were
were different for negative and non-integer numbers!!

UDf provide a level of encapsulation. When porting from one DBMS to
another UDF can be used to emulate the other DBMS's semantics including
funny MODs. E.g. the DB2 migration toolkit provides librraies fro
Sybase, SQL Server and Oracle functions. Without UDF porting would be
next to impossible.
Also note that SQL Functions in DB2 are SQL/PSM compliant. <<

But other 3GLs do not.

You brought up SQL/PSM.... and you use it in your own books.

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

This discussion thread is closed

Replies have been disabled for this discussion.