Re: How to convert carriage return to another char string in Informix SQL or 4GL
Posted in 2004
Have you tried using C escapes from 4GL (\\r or \\015 for <CR>, \\n or \\012 for <LF>)? Mind you, I am not at all sure that will work, haven't used 4GL in more than a decade, don't remember whether strings are ordinary C char arrays and don't have docs :-) Alternatively, you could write your own little C function to do that and link it into your 4GL program (or even massage ESQL/C files - those with .ec extension - that are result of the first phase of 4GL compilation - dirty but quick ;-) Cheers! Dragi "Bonzi" Raos Zagreb, Croatia ----- Original Message ----- From: "Wayne T" <ntrieu@yahoo.com> To: <informix-list@iiug.org> Sent: Friday, January 02, 2004 3:55 PM Subject: How to convert carriage return to another char string in Informix SQL or 4GL > I am post this question for my co-worker, here is his questions. Any > help would be appreciated. > > Hi, > > In a databse table there is a field of type character or string - or > whatever informix calls it. This string contains new line characters > or carriage returns. > In a 4gl program this field is queried and printed. > > Just before this field is printed the line number internal variable > "lineno" is , say, 10. Then this field is printed. Lets say the field > has one new line character > ( IN other words the field contains" > > Hello, > How are you." > ) > > As you can see the field has one new line character after "Hello," > since there are two lines. > > Immediately after printing the above field value, the line number > internal variable "lineno" is , 12. > It should be 13 since two lines have been used by the field. > > This causes the "skip to top of page" command to not really skip to > the top of the page and report format is all messed up. > We need this fixed. > > But for now, as a work around, if I can replace any occurence of "new > line" or "carriage return" with a space or a dash, I can live with > that > but unfortunately I can't find a way to type in the "new line" > character in the function call. > > For example, in order to replace any occurence of "y" with a "z" in > the string "xyz" > I will use this sql function: > > replace("xyz", "y", "z") > the result will be "xzz". > > Here I specified the character "y" to be replaced. > How do I specify that I need to replace a "carriage return" or a > "newline" character. > I tried '^M' but this did not work. > sending to informix-list