Assigning a concatenated value to a string : String Calculation « Postgre SQL « PostgreSQL






Assigning a concatenated value to a string


postgres=#
postgres=#
postgres=# -- Assigning a concatenated value to a string
postgres=#
postgres=# CREATE FUNCTION title_and_author (text, text) RETURNS text AS '
postgres'#     DECLARE
postgres'#         -- Declare aliases for the two function arguments.
postgres'#        title ALIAS for $1;
postgres'#        author ALIAS for $2;
postgres'#        result text;
postgres'#
postgres'#     BEGIN
postgres'#        result := title || '', by '' || author;
postgres'#         -- Return the resulting string.
postgres'#        return result;
postgres'#
postgres'#     END;
postgres'# ' language 'plpgsql';
CREATE FUNCTION
postgres=#
postgres=# select title_and_author('a','b');
 title_and_author
------------------
 a, by b
(1 row)

postgres=#
postgres=#
           
       








Related examples in the same category

1.Joined words