I’m querying the DB and need to parse one of the fields for specific values (using string functions). So I figured it’d be best to write a function for it. I’ve never written a function before in plsql, so I decided to look at some examples.
I got a copy of a simple “square” function which takes a number and returns the square of it, but am not sure how to call it from the SQL statement.
I only have read access. Will I be able to write functions and use them to retrieve the data I need? And if so, how?
To be able to create a function your user needs the CREATE PROCEDURE privilege granted to it by the DBA:
If you have the privilege then you can create a function like this
And you can call it from SQL like this:
Note: in Oracle it is usually preferred to create functions in packages, in which case the calling SQL would be like: