Reputation: 21
I would like to use a function like this
CREATE FUNCTION substr_beginning_end (long_text text, substr_beginning VARCHAR(50), substr_end VARCHAR(20))
RETURNS VARCHAR(2000) DETERMINISTIC
RETURN SUBSTR(long_text,
POSITION(substr_beginning IN long_text) + LENGTH(substr_beginning),
LOCATE(substr_end, long_text, POSITION(substr_beginning IN long_text))-POSITION(substr_beginning IN long_text) - LENGTH(substr_beginning)
);
But I have only execution privileges on the database and procedures.
Is there a way to just use a function without having permissions for creating such a function in the database?
Upvotes: 1
Views: 383
Reputation: 21
Based on Creating Temp Variables within Queries:
SELECT
CONCAT_WS( if(@campo1_substr_beginning := 'feature01":"', '',''),
if(@campo1_substr_end := '",', '',''),
SUBSTR(request, POSITION(@campo1_substr_beginning IN request) + LENGTH(@campo1_substr_beginning),
LOCATE(@campo1_substr_end, request, POSITION(@campo1_substr_beginning IN request))
- POSITION(@campo1_substr_beginning IN request)
- LENGTH(@campo1_substr_beginning)
) ) AS 'campo1',
CONCAT_WS( if(@campo3_substr_beginning := '"feature02":', '',''),
if(@campo3_substr_end := ',', '',''),
SUBSTR(request, POSITION(@campo3_substr_beginning IN request) + LENGTH(@campo3_substr_beginning),
LOCATE(@campo3_substr_end, request, POSITION(@campo3_substr_beginning IN request))
- POSITION(@campo3_substr_beginning IN request)
- LENGTH(@campo3_substr_beginning)
) ) AS 'campo3',
request,
response
FROM event_log elog
WHERE
....
Upvotes: 1