MySQL Forums :: InnoDB :: String cuts in column data


Advanced Search

Re: String cuts in column data
Posted by: Peter Brawley ()
Date: February 09, 2017 03:29AM

If you're a regular regex user in a real language (eg Perl, PHP, C), that'll be easier, otherwise it's just a few lines of brute force string parsing ...

set @s = "[CALL DATE : 11/23/2015] [CONTACT NAME : venki palama] [SERVICE REP NAME : sudhakar mare] Please send a picture showing the overlay harness and connections made";

set @stop = locate("]",@s,1);
set @calldate = trim( substr( @s, 14, @stop-14 );

set @start = locate("[",@s,@stop);
set @stop = locate("]",@s,@start);
set @preflen = length(" [CONTACT NAME ");
set @contactname = trim( substr(@s, @start + @preflen, @stop-@start-@preflen) );

set @start = locate("[",@s,@stop);
set @stop = locate("]",@s,@start);
set @preflen = length(" [SERVICE REP NAME ");
set @servicerepname = trim( substr(@s, @start + @preflen, @stop-@start-@preflen) );

set @comment = trim( substring_index(@s,']',-1) );

select @calldate, @contactname, @servicerepname, @comment;

Easy to make a func of it, call it as often as you please.

Options: ReplyQuote


Subject Views Written By Posted
String cuts in column data 139 Ra Nala 02/08/2017 10:59AM
Re: String cuts in column data 76 Peter Brawley 02/08/2017 01:20PM
Re: String cuts in column data 86 Jon Stephens 02/08/2017 08:05PM
Re: String cuts in column data 74 Ra Nala 02/09/2017 12:31AM
Re: String cuts in column data 82 Peter Brawley 02/09/2017 03:29AM
Re: String cuts in column data 120 Ra Nala 02/09/2017 05:59AM
Re: String cuts in column data 84 Peter Brawley 02/09/2017 12:43PM
Re: String cuts in column data 132 Jon Stephens 02/09/2017 08:50PM


Sorry, only registered users may post in this forum.

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.