Yes, I think you could do this using a stored procedure.
It would have to have a REPEAT loop that uses LOCATE to find the row index of the next token '${' , takes a name from there to the next LOCATE d '}' and replaces CONCAT and SUBSTRING with a value. If this value comes from a simple table of matching names to a value that is not so bad, but if you want ${first_name} actually use a column named first_name , you would need to create dynamic SQL in the row and run it using PREPARE...EXECUTE that is ugly and dangerous.
It would be complex, fragile, and dependent on the DBMS. SQL is not really intended for convenient use. Any universal programming language with reasonable string manipulation tools should be able to do this in a much simpler way. If you have PHP, use it.
source share