All Forums Extensibility
gpolanch 46 posts Joined 12/11
30 Jan 2012
What is allowed in an SQL UDF?


I've written some C-language UDF's but management is not keen on using C.  I recently discovered that SQL UDF's are available in 13.10, but I am unclear as to what is allowed to be contained in an SQL UDF.  The most info I have seen is in the doc SQL Functions, Operators, Expressions, and Predicates (Rel 13.10).  But, the examples in this doc contain only the simplest of logic  (ie.  RETURN a + b).   Is there a doc with more detailed info and examples?

What else can be done in an SQL UDF?  Can any elements of the stored procedure language be used in an SQL UDF?  Can I loop through a character string, making decisions as I go?  My goal is to be able to implement the Oracle REPLACE() function (replace a string with another string), and implement some specific uses of the Oracle REGEXP_LIKE() function (for example,  return TRUE if the first character of a string is letters E or V, followed by 4 numeric characters, a dot, and two more numeric characters). 

Thanks much!

ulrich 816 posts Joined 09/09
30 Jan 2012

my understanding is that an SQL UDF can contain everything which can be done with a standard SQL which result in a single value output.

Think of SQL UDF simple code wrapper which will be replaced when the SQL is executed.

So you can call different functions, do complex case statements etc. No loops.

Check also for replace and there might be also the reg expression available somewhere.

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

You must sign in to leave a comment.