How to create a QUOTENAME function in mySQL

I would like to create a QUOTENAME () function in mySQL, similar to the one that exists in M ​​$ SQL Server.

This is what it does:

QUOTENAME returns a Unicode string with the delimiters added to make the input string a valid identifier. The QUOTENAME function uses this syntax:

QUOTENAME ( 'string' [ , 'delimiter' ] ) 

You pass QUOTENAME a string to be delimited and a one-character string to use as the delimiter. The delimiter can be a square bracket or a single or double quotation mark.

Is it possible?

+3
source share
1 answer

You can start with something like this: build an eggyal comment

DROP FUNCTION IF EXISTS QUOTENAME;

CREATE FUNCTION QUOTENAME (s varchar(50), d CHAR(1))
RETURNS VARCHAR(52)
RETURN CONCAT (d, REPLACE(s, d, CONCAT(d,d)), d);

Then add special cases and extra features.

0
source

All Articles