SQL Offers a host of powerful scalar functions. Nearly every one of these functions can be "wrapped" in an RPGLE subprocedure.
Using an SQL Scalar Function can be a lot easier than the RPG alternative:
The SQLSCALAR service program contains subprocedure wrappers for the SQL scalar functions ABS, ACOS, ANTILOG, ASCII, ASIN, ATAN, ATAN2, ATANH, BIT_LENGTH, CEIL, CHR, COALESCE, COS, COSH, COT, DATABASE, DAYNAME, DAYOFWEEK, DAYOFWEEK_ISO, DAYOFYEAR, DECRYPT_CHAR, DEGREES, DIFFERENCE, ENCRYPT_AES, ENCRYPT_RC2, ENCRYPT_TDES, EXP, FLOOR, GETHINT, HEX, IFNULL, JULIAN_DAY, LAND, LAST_DAY, LCASE, LEFT, LN, LNOT, LOG10, LOR, LOWER, LPAD, MAX, MIDNIGHT_SECONDS, MIN, MONTHNAME, NEXT_DAY, PI, QUARTER, RADIANS, RAND, REGEXP_COUNT, REGEXP_INSTR, REGEXP_REPLACE, REGEXP_SUBSTR, REPLACE, RIGHT, ROUND_TIMESTAMP, RPAD, SIN, SINH, SOUNDEX, TAN, TANH, TRUNC_TIMESTAMP, TRUNCATE, UCASE, UPPER, VALUE, WEEK, WEEK_ISO and XOR.
The download is a zip file containing a save file (1.9M) of the SQLSCALAR library and a READ_ME document which contains details on how to install and use the service program.
Check out the article at IT Jungle.
Please note that these are not supported products - the source of the programs is included and you are free to chop and change them as you wish (see standard disclaimer below). Of course, if you come across any bugs please let us know.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
As the SiD team or as individuals, Paul Tuohy, Susan Gantner, and Jon Paris offer a
wide range of custom services to help you leverage
key IBM i technologies in your unique environment.
Take a giant leap forward in one of today's critical IBM i development skills. These live workshops offer a half day of in-depth learning with practical code examples and handouts to continue using as a reference.
Available free through May 31, 2022, these 75-minute sessions cover technical tips and IBM i development tool demos. Featuring Paul Tuohy, Susan Gantner, Jon Paris, and their ISV guests.