<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='mso-fareast-language:EN-US'>Hi Marty,<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>I think your pain has a name : Transliteration<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>Roy invented some ‘baroque’ SQL for a customer recently which did the job for a varchar(25) to correct a load of issues for soundex_dm computed values.<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>I’m not sure it would scale to 12,000 as the working part of the SQL Insert / select had hard coded ordinal positions for each character.<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>It’s the closest I’ve seen SQL being made to look like some C-Language gobbledygook.<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>I’ll let him explain.<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>Cheers<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>Adrian<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US>From:</span></b><span lang=EN-US> info-ingres-bounces@lists.planetingres.org <info-ingres-bounces@lists.planetingres.org> <b>On Behalf Of </b>Martin Bowes<br><b>Sent:</b> 31 August 2018 11:41<br><b>To:</b> info-ingres@lists.planetingres.org<br><b>Subject:</b> [Info-ingres] More similar to<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi All,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I just knew this non printing character stuff was going to come back and bite me…<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I can identify the rows with non printing characters excluding \t, \r and \n.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Now I need to find which characters are being objected to on each row. I may need to know their position as well.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The data in question is a long varchar. But (fortunately) the longest item is under 12000 characters, so we are under the 32000 char varchar conversion limit.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The easiest way I can think of doing this is to do it in a database procedure…<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-family:"Courier New"'>create procedure identify_bad_char<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'>as declare<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> snapshot_id integer4 not null not default;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> res_note long varchar not null not default;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> msgid integer4 not null not default;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> msg varchar(256) not null not default;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'>begin<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> msgid = 0;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> FOR SELECT snapshot_id, res_note INTO :snapshot_id, :res_note<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> FROM basket_snapshot<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> WHERE res_note SIMILAR TO '%[^' + x'09' + x'0a' + x'0d' + '[:print:]]%'<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> DO<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> msgid = msgid + 1;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> msg = 'res_note for snapshot_id = ' + varchar(:snapshot_id) + ' is dodgy.';<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> message :msgid :msg;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> /* Insert manic while loop here and process the line character by character */<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> ENDFOR;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'>end;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal>Before I start coding up the manic while loop … does anyone have a suggestion as to how I can do this more efficiently.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The data was probably added to a web form via a cut and paste from a word document, so we’ve picked up things like smart quotes. Hence we may ultimately be interested in replacing multi character sequences with simple ansi equivalents. I have a suspicion a clean() function is galloping in my direction.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Martin Bowes<span style='font-family:"Courier New"'><o:p></o:p></span></p></div></body></html>