views:

104

answers:

2

is it possible to select colums and do complex operations on them for example select factorial(column1) from table1 or select integral_of(something) from table2

perhaps there are libraries that support such operations?

+3  A: 

Yes, it is. If the function you want is not built into your RDBMS, you can write your own User Defined Functions.

You'll find an example here: http://www.15seconds.com/Issue/000817.htm.

RedFilter
+11  A: 

Yes, you can call all pre-defined functions of your DB on the select columns and you can use CREATE FUNCTION to define your own.

But DBs are meant to wade through huge amounts of data, not to do complex calculations on them. If you try this, you'll find that many operations are awfully slow (especially the user defined ones).

Which is why most people fetch the data from the database and then do the complex math on the application side. This also makes it more simple to test and optimize the code or replace it with a new version.

Aaron Digulla