Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / Informix Topics / May 2008

Tip: Looking for answers? Try searching our database.

Non-printable sign

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DeMi - 26 May 2008 10:23 GMT
Hello,

I have problem with replacing non-printable 'new line' sign (^J) to
null. Actually, I don't know if Informix provides function like
Oracle's ord() or ascii() which would be helpful.
My task is to unload rows from sql query into file with default
delimiter '|'. It is very important that each record is written in one
separate line. However, it happens that one field can contain the 'new
line' sign. In this case my row is split into two lines which is not
allowed. The interested field is varchar type.

Does anybody solved this kind of problem and how?

Best regards
Michal Demyda
Michael Krzepkowski - 26 May 2008 21:18 GMT
> Hello,
>
[quoted text clipped - 11 lines]
> Best regards
> Michal Demyda

You should be able to strip these with tr and sed in a script.

Informix has ascii(), but this would require retrieving of this field,
cleaning it up and
then output to file. You can do this is 4GL

HTH

Michael
Ian Michael Gumby - 27 May 2008 00:17 GMT
On May 26, 3:18 pm, Michael Krzepkowski <mkrzepkow...@gmail.com>
wrote:
> > Hello,
>
[quoted text clipped - 21 lines]
>
> Michael

If the data is already in the database, then you'll need to select the
bad records and replace them with the stripped out characters.
Oracle 10g and later has a regex function which you could use to find
non-printable "white space" within a string. (Your EOL, Ret, etc ...)

I believe there is a regex function in IDS, if not, you can write one
in C or Java as a UDR/UDF that could be used to strip out the data via
an SQL statement, or you could have a before insert trigger call the
function passing in the field and then returning the cleansed data to
be inserted.

The reason I would recommend this over a sed/awk or python script is
that by putting this in the engine, you allow it to be used by other
applications or non-sever centric sources of data. (An example would
be allowing the app to be run on a pc and the data is local to the pc
and not the server.)

HTH

-G
Jonathan Leffler - 27 May 2008 13:54 GMT
> I have problem with replacing non-printable 'new line' sign (^J) to
> null. Actually, I don't know if Informix provides function like
[quoted text clipped - 6 lines]
>
> Does anybody solved this kind of problem and how?

It strikes me that replacing the newlines with ASCII NUL '\0' would
not be a good idea; that would mark the end of the string and
effectively truncate anything after the newline.  You would probably
be better of replacing it with a blank.

For mechanics, you should look at the REPLACE function - assuming you
have a sufficiently recent version of IDS.  There is also an ASCII
function in IDS (11.50 at least, but I believe at least some earlier
versions).  There doesn't seem to be an ORD() or CHR() function built
in -- odd, I thought it was added at the same time as ASCII (it should
have been).

If you poke around the IIUG web site, you should find a package
ascii.tgz containing a now redundant ASCII function and a still
relevant CHR function plus the data for a table which those functions
use - and a script to assemble it all.  (Contents: ascii.sql,
ascii.unl, asciitbl.sql, chr.sql, mkascii.sql)  If you really can't
find that after some searching, contact me.  You'd then use CHR(10) in
the REPLACE function search string.  There are probably other ways of
doing it too.

-=JL=-
Konikoff, Robert W MAJ RET - 27 May 2008 16:32 GMT
I went to the IIUG software area, and all it has were links to:
IDS-11.5
OAT
Server Studio
Sentinel
Member Area Home

So where can I find ascii.tgz ??

Thanks...

Rob
-----Original Message-----
From: informix-list-bounces@iiug.org [mailto:informix-list-bounces@iiug.org]
On Behalf Of Jonathan Leffler
Sent: Tuesday, May 27, 2008 7:54 AM
To: informix-list@iiug.org
Subject: Re: Non-printable sign

On May 26, 2:23 am, DeMi <michal.dem...@gmail.com> wrote:
> I have problem with replacing non-printable 'new line' sign (^J) to
> null. Actually, I don't know if Informix provides function like
[quoted text clipped - 6 lines]
>
> Does anybody solved this kind of problem and how?

It strikes me that replacing the newlines with ASCII NUL '\0' would
not be a good idea; that would mark the end of the string and
effectively truncate anything after the newline.  You would probably
be better of replacing it with a blank.

For mechanics, you should look at the REPLACE function - assuming you
have a sufficiently recent version of IDS.  There is also an ASCII
function in IDS (11.50 at least, but I believe at least some earlier
versions).  There doesn't seem to be an ORD() or CHR() function built
in -- odd, I thought it was added at the same time as ASCII (it should
have been).

If you poke around the IIUG web site, you should find a package
ascii.tgz containing a now redundant ASCII function and a still
relevant CHR function plus the data for a table which those functions
use - and a script to assemble it all.  (Contents: ascii.sql,
ascii.unl, asciitbl.sql, chr.sql, mkascii.sql)  If you really can't
find that after some searching, contact me.  You'd then use CHR(10) in
the REPLACE function search string.  There are probably other ways of
doing it too.

-=JL=-
_______________________________________________
Informix-list mailing list
Informix-list@iiug.org
http://www.iiug.org/mailman/listinfo/informix-list
Jonathan Leffler - 28 May 2008 05:44 GMT
> I went to the IIUG software area, [...]
> So where can I find ascii.tgz ??

http://www.iiug.org/software/index_MISC.html

It's listed as just ASCII - but the download is ascii.tgz

Repository search on ASCII lists this - not top, but close.

> On Behalf Of Jonathan Leffler
> [...]
> If you poke around the IIUG web site, you should find a package
> ascii.tgz

Signature

Jonathan Leffler                   #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2008.0229 -- http://dbi.perl.org/

publictimestamp.org/ptb/PTB-3349 ripemd256 2008-05-28 03:00:06
C3D596E9F6498794084AC7CDDB8CE7678DE25C29C18FA51D9147A0AC69D6AA9A

Claus Samuelsen - 27 May 2008 17:26 GMT
> Hello,
>
[quoted text clipped - 11 lines]
> Best regards
> Michal Demyda

Install the IDS regex bladelet (see Jean Anderson's article:
http://www.ibm.com/developerworks/db2/zones/informix/library/techarticle/db_rege
xp.html
)
and the do something like:

SELECT regex_replace(myvarchar,'\n',' ') from mytable ...

That's it!
Doug Lawry - 27 May 2008 20:32 GMT
EXECUTE PROCEDURE IFX_ALLOW_NEWLINE('T');

SELECT REPLACE(varchar-column, '
', ' '),
...

Regards,
Doug Lawry

> Hello,
>
[quoted text clipped - 11 lines]
> Best regards
> Michal Demyda
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.