MySQL Forums
Forum List  »  Triggers

Re: Trigger to replace string
Posted by: Devart Team
Date: February 25, 2011 06:19AM

The syntax can be like this -

DELIMITER $$

CREATE TRIGGER cp
BEFORE UPDATE
ON clientsshared
FOR EACH ROW
BEGIN
  SET @tech_prefix = NEW.tech_prefix;
  IF @tech_prefix LIKE '%CP:000%' THEN
    SET @pos = LOCATE('CP:', @tech_prefix) + 3;
    SET @len = LOCATE(';', @tech_prefix, @pos) - @pos;
    SET NEW.tech_prefix = INSERT(@tech_prefix, @pos, @len, '48222111444');
  END IF;
END
$$

DELIMITER ;

Devart Company,
MySQL management tools
http://www.devart.com/dbforge/mysql/

Options: ReplyQuote


Subject
Views
Written By
Posted
6209
February 24, 2011 09:48AM
2189
February 24, 2011 10:08AM
2236
February 24, 2011 11:42AM
Re: Trigger to replace string
2385
February 25, 2011 06:19AM
1933
February 25, 2011 07:00AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.