How to query for LineFeed characters ?
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Data Types & Schema Design, Platform-Specific Issues
How to select only the rows that contains a LF (Linefeed) or CR (Carriage
Return) characters from a column with using like,
I tried several ways with ESQL/C but without any luck using \\n or the \\xa as
hexadecimal.
here is an example:
select MyColumn from Mytable where MyColumn like '%\\\\n%'
or
select MyColumn from Mytable where MyColumn like '%\\\\xa%'
any idea how to insert them too?
Note : MyColumn is defined as varchar(20).
We are using Informix Dynamic Server 2000 Version 9.20.UC2 on solaris 6.
Thanks.
Mahmoud Kamoun
Mahmoud Kamoun wrote:
> How to select only the rows that contains a LF (Linefeed) or CR (Carriage
> Return) characters from a column with using like,
Interesting problem.
> I tried several ways with ESQL/C but without any luck using \\n or the \\xa as
> hexadecimal.
>
> here is an example:
>
> select MyColumn from Mytable where MyColumn like '%\\\\n%'
> or
> select MyColumn from Mytable where MyColumn like '%\\\\xa%'
That won't work unless you've got a server that allows you to say "Allow
newlines in character strings". I think that 9.20 is in that category;
I don't immediately recall what you have to set to allow it.
However, you could prepare a statement such as:
$ PREPARE p FROM "SELECT MyColumn FROM MyTable WHERE MyColumn LIKE ?";
$ DECLARE c CURSOR FOR p;
and then supply a parameter with "%\\n%" as the C string value:
$ char *xyz = "%\\n";
$ OPEN c USING $xyz;
...
> any idea how to insert them too?
Same basic idea: use place holders.
> Note : MyColumn is defined as varchar(20).
> We are using Informix Dynamic Server 2000 Version 9.20.UC2 on solaris 6.
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
"I don't suffer from insanity; I enjoy every minute of it!"
Do this:
- vi cr_file and insert CTRL-v CTRL-m (insert by pressing control-v
then control-m), and save.
- in dbaccess, type:
create temp table cr_temp (cr_char char(1));
load from cr_file insert into cr_temp;
select MyColumn from Mytable
where McColumn like "%"||(select cr_char from cr_temp)||"%";
Erickson
In article <G57o9y.DwF@igsrsparc2.er.usgs.gov>,
"Mahmoud Kamoun" <kamounm@usgs.gov> wrote:
> How to select only the rows that contains a LF (Linefeed) or CR
(Carriage
> Return) characters from a column with using like,
>
> I tried several ways with ESQL/C but without any luck using \\n or the
\\xa as
> hexadecimal.
>
> here is an example:
>
> select MyColumn from Mytable where MyColumn like '%\\\\n%'
> or
> select MyColumn from Mytable where MyColumn like '%\\\\xa%'>
> any idea how to insert them too?
>
> Note : MyColumn is defined as varchar(20).
> We are using Informix Dynamic Server 2000 Version 9.20.UC2 on
solaris 6.
>
> Thanks.
>
> Mahmoud Kamoun
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.