How to write a custom function in SQL? #4850
-
Dear all. The Script Repository has some fine examples of how to write a custom function in either Javascript or TCL. Unfortunately, there are no examples for custom functions written in SQL in the documentation. Example: Let's assume we want to create a scalar function In Javascript there is the Any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
By looking at the code, it seems there are 3 formats of variables allowed:
The "var_name" part should be aligned with named arguments of the function. If I'm not mistaken, the SQL-implemented does not allow using arguments if the function does not explicitly list them as named arguments. I haven't tested it (I'm on holidays at the moment, I don't have possibility to try it out). |
Beta Was this translation helpful? Give feedback.
I believe your
leftstr
implementation code should start withSELECT
first. The implementation code has to be a full, valid SQL statement, not just expression, because it allows alsoINSERT
s,UPDATE
s,DELETE
s and even multiple SQL statements as single function.