Commit 9d5751f6 authored by Carsten  Rose's avatar Carsten Rose

Add QIFEMPTY().

parent 2c6246ad
Pipeline #2203 passed with stages
in 2 minutes and 44 seconds
......@@ -6729,9 +6729,24 @@ Example::
10.sql = SELECT QMORE("This is a text which is longer than 10 characters", 10)
Output:
Output::
This is a `more..`
This is a `more..`
.. _qifempty:
QIFEMPTY: if empty show token
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The SQL function QIFEMPTY(input, token) returns 'token' if 'input' is empty else 'input'.
Example::
10.sql = SELECT QIFEMPTY('hello world','-'), QIFEMPTY('','-')
Output::
hello world-
.. _download:
......
......@@ -51,7 +51,6 @@ SET output = REPLACE(input, '|', '\\|');
RETURN output;
END;
###
#
# QNL2BR(input)
......@@ -65,4 +64,19 @@ BEGIN
DECLARE output TEXT;
SET output = REPLACE( REPLACE(input, CHAR(13), ''), CHAR(10), '<br>');
RETURN output;
END
\ No newline at end of file
END;
###
#
# QIFEMPTY(input, token)
# If 'input' is empty, replaces by 'token'
#
DROP FUNCTION IF EXISTS QIFEMPTY;
CREATE FUNCTION QIFEMPTY(input TEXT, token TEXT)
RETURNS TEXT
DETERMINISTIC
BEGIN
DECLARE output TEXT;
SET output = IF(input = '', token, input);
RETURN output;
END;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment