Friday, 15 March 2013

stored procedures - mysql replace character at position -



stored procedures - mysql replace character at position -

if have variable in stored procedure this: declare str varchar(10); set str = 'abcd';

how alter character in string @ arbitrary position? example: in procedure x 3. need alter str becomes str = 'ab*d';

this means that, x equals 3, in string, character @ position 3, should changed '*'.

you can string manipulations:

select concat(left(str, 2), '*', substring(str, 4, 10))

or, can utilize insert() function:

select insert(str, 3, 1, '*')

mysql stored-procedures

No comments:

Post a Comment