Use of tab delimiter in ISQL
Posted in 2011
The poster wanted an UNLOAD in an isql here-document script to produce a tab-delimited file and couldn't get TAB accepted as the delimiter. Suggestions: type a literal tab key between the quotes in the DELIMITER clause (or set DBDELIMITER to a literal tab) rather than using \\\\t or ascii9 — Jonathan Leffler confirmed this works with db-access/isql; alternatively unload with a unique placeholder string and convert it to tabs afterwards with sed. The poster confirmed it worked. A follow-up question about date arithmetic in shell scripts drew answers using GNU date -d "-1 day"/"1 day ago", though the poster was on Tru64.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Migration, Import/Export & Data Conversion
Hi all,
I am suddenly stuck when trying to use TAB as a delimiter in an unload
statement embedded in a unix script:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/ksh
isql $DBPATH/ttlabs 2>/dev/null << !
unload to ln1_delemiter_tab delimiter "want- to -use- tab-as-delimiter"
select request,invoice_centre
from rq
where invoice_centre is not null!
exit
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
So far I am just used to ";" or | as default delimiter.
I tried ascii9 and the "Tab" key but could not get the right result.
I don't want to use awk (OFS="\\\\t") to implement this, thinking the simple way
to create a file with Tab as delimiter after the SQL is executed.
Any hint would be highly appreciated.
Env: Informix SE, ISQL 7.3.
Truly yours,
Long Nguyen
Have you tried delimiter "<tab key>"(with quotes)?
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Long
Nguyen
Sent: Tuesday, 15 March 2011 12:12 PM
To: ids@iiug.org
Subject: Use of tab delimiter in ISQL [23083]
Hi all,
I am suddenly stuck when trying to use TAB as a delimiter in an unload
statement embedded in a unix script:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/ksh
isql $DBPATH/ttlabs 2>/dev/null << !
unload to ln1_delemiter_tab delimiter "want- to -use- tab-as-delimiter"
select request,invoice_centre
from rq
where invoice_centre is not null!
exit
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
So far I am just used to ";" or | as default delimiter.
I tried ascii9 and the "Tab" key but could not get the right result.
I don't want to use awk (OFS="\\\\t") to implement this, thinking the simple way
to create a file with Tab as delimiter after the SQL is executed.
Any hint would be highly appreciated.
Env: Informix SE, ISQL 7.3.
Truly yours,
Long Nguyen
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
***************************************************************
This message is intended for the addressee named and may contain confidential
information. If you are not the intended recipient, please delete it and
notify the sender. Views expressed in this message are those of the individual
sender, and are not necessarily the views of the Land and Property Management
Authority. This email message has been swept by MIMEsweeper for the presence
of computer viruses.
***************************************************************
Please consider the environment before printing this email.
Or do it after the fact
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/ksh
isql $DBPATH/ttlabs 2>/dev/null << !
unload to ln1_delemiter_Xs delimiter "XXXXXXXXXXXXX"
select request,invoice_centre
from rq
where invoice_centre is not null!
sed "s/XXXXXXXXXXXXX/\\\\t/g; w ln1_delemiter_tabs" ln1_delemiter_Xs
exit
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Jim Chen
Sent: Tuesday, 15 March 2011 2:19 p.m.
To: ids@iiug.org
Subject: RE: Use of tab delimiter in ISQL [23084]
Have you tried delimiter "<tab key>"(with quotes)?
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Long
Nguyen
Sent: Tuesday, 15 March 2011 12:12 PM
To: ids@iiug.org
Subject: Use of tab delimiter in ISQL [23083]
Hi all,
I am suddenly stuck when trying to use TAB as a delimiter in an unload
statement embedded in a unix script:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/ksh
isql $DBPATH/ttlabs 2>/dev/null << !
unload to ln1_delemiter_tab delimiter "want- to -use- tab-as-delimiter"
select request,invoice_centre
from rq
where invoice_centre is not null!
exit
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
So far I am just used to ";" or | as default delimiter.
I tried ascii9 and the "Tab" key but could not get the right result.
I don't want to use awk (OFS="\\\\t") to implement this, thinking the simple way
to create a file with Tab as delimiter after the SQL is executed.
Any hint would be highly appreciated.
Env: Informix SE, ISQL 7.3.
Truly yours,
Long Nguyen
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
***************************************************************
This message is intended for the addressee named and may contain confidential
information. If you are not the intended recipient, please delete it and
notify the sender. Views expressed in this message are those of the individual
sender, and are not necessarily the views of the Land and Property Management
Authority. This email message has been swept by MIMEsweeper for the presence
of computer viruses.
***************************************************************
Please consider the environment before printing this email.
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
DISCLAIMER
This email contains information that is confidential and which may be legally
privileged. If you have received this email in error, please notify the sender
immediately and delete the email. This email is intended solely for the use of
the intended recipient and you may not use or disclose this email in any way.
On Mon, Mar 14, 2011 at 18:12, Long Nguyen <longhuynguyen51@yahoo.com.au>wrote:
> I am suddenly stuck when trying to use TAB as a delimiter in an unload
> statement embedded in a unix script:
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> #!/bin/ksh
> isql $DBPATH/ttlabs 2>/dev/null << !
> unload to ln1_delemiter_tab delimiter "want- to -use- tab-as-delimiter"
> select request,invoice_centre
> from rq
> where invoice_centre is not null> !
> exit
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> So far I am just used to ";" or | as default delimiter.
> I tried ascii9 and the "Tab" key but could not get the right result.
> I don't want to use awk (OFS="\\\\t") to implement this, thinking the simple
> way
> to create a file with Tab as delimiter after the SQL is executed.
> Any hint would be highly appreciated.
> Env: Informix SE, ISQL 7.3.
>
One technique that worked for me:
DBDELIMITER='<tab>' dbaccess stores - <<!
unload to "elements.data" select * from elements;!
That gave me the output with tabs in it. I hit the TAB key between the two
single quotes.
I got the same effect when I put the "delimiter '<tab>' " clause into the
SQL as shown.
If you are using the built-in ISQL command editor - well, why would you be
doing that? Set DBEDIT=vim (or vi, or emacs, or any other editor) and use
that instead.
That was tested with DB-Access from IDS 11.70.FC1 on RHEL 5.
I got the same result with ISQL 7.50.UC1 against the same server on RHEL 5
again.
--
Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h>
Guardian of DBD::Informix - v2008.0513 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
--00151747bfde70fc9b049e7b6498
Thanks Jarrod and Jonathan,
It works!
By the way another request: How to calculate a date in a Unix script, eg today
-
n days?
Any simple command using date for such date computing like in 4GL let date_calc
= today - n days?
OS: HP's Thru 64
Cheers,
Long N.
________________________________
From: Jarrod Teale <Jarrod.Teale@fonterra.com>
To: ids@iiug.org
Sent: Tue, 15 March, 2011 12:25:58 PM
Subject: RE: Use of tab delimiter in ISQL [23085]
Or do it after the fact
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/ksh
isql $DBPATH/ttlabs 2>/dev/null << !
unload to ln1_delemiter_Xs delimiter "XXXXXXXXXXXXX"
select request,invoice_centre
from rq
where invoice_centre is not null!
sed "s/XXXXXXXXXXXXX/\\\\t/g; w ln1_delemiter_tabs" ln1_delemiter_Xs
exit
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Jim Chen
Sent: Tuesday, 15 March 2011 2:19 p.m.
To: ids@iiug.org
Subject: RE: Use of tab delimiter in ISQL [23084]
Have you tried delimiter "<tab key>"(with quotes)?
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Long
Nguyen
Sent: Tuesday, 15 March 2011 12:12 PM
To: ids@iiug.org
Subject: Use of tab delimiter in ISQL [23083]
Hi all,
I am suddenly stuck when trying to use TAB as a delimiter in an unload
statement embedded in a unix script:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/ksh
isql $DBPATH/ttlabs 2>/dev/null << !
unload to ln1_delemiter_tab delimiter "want- to -use- tab-as-delimiter"
select request,invoice_centre
from rq
where invoice_centre is not null!
exit
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
So far I am just used to ";" or | as default delimiter.
I tried ascii9 and the "Tab" key but could not get the right result.
I don't want to use awk (OFS="\\\\t") to implement this, thinking the simple way
to create a file with Tab as delimiter after the SQL is executed.
Any hint would be highly appreciated.
Env: Informix SE, ISQL 7.3.
Truly yours,
Long Nguyen
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
***************************************************************
This message is intended for the addressee named and may contain confidential
information. If you are not the intended recipient, please delete it and
notify the sender. Views expressed in this message are those of the individual
sender, and are not necessarily the views of the Land and Property Management
Authority. This email message has been swept by MIMEsweeper for the presence
of computer viruses.
***************************************************************
Please consider the environment before printing this email.
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
DISCLAIMER
This email contains information that is confidential and which may be legally
privileged. If you have received this email in error, please notify the sender
immediately and delete the email. This email is intended solely for the use of
the intended recipient and you may not use or disclose this email in any way.
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
% date "+%d.%m.%Y" 17.03.2011 % date -d "-1 day" "+%d.%m.%Y" 16.03.2011 % date "+%s" # number of seconds since the Unix epoch 1300362148 HTH Hrvoje On 17.03.2011. 12:31, Long Nguyen wrote: > Thanks Jarrod and Jonathan, > It works! > By the way another request: How to calculate a date in a Unix script, eg today > - > n days? > Any simple command using date for such date computing like in 4GL let > date_calc > = today - n days? > OS: HP's Thru 64 > Cheers, > Long N. > > ____ >
date -d "1 day ago" +%Y%m%d
works min. for linux. Did not try in other OS.
Marcus
-----Original Message-----
From: Long Nguyen [mailto:longhuynguyen51@yahoo.com.au]
Sent: Thursday, March 17, 2011 12:32 PM
To: ids@iiug.org
Subject: Re: Use of tab delimiter in ISQL [23139]
Thanks Jarrod and Jonathan,
It works!
By the way another request: How to calculate a date in a Unix script, eg
today
-
n days?
Any simple command using date for such date computing like in 4GL let
date_calc = today - n days?
OS: HP's Thru 64
Cheers,
Long N.
________________________________
From: Jarrod Teale <Jarrod.Teale@fonterra.com>
To: ids@iiug.org
Sent: Tue, 15 March, 2011 12:25:58 PM
Subject: RE: Use of tab delimiter in ISQL [23085]
Or do it after the fact
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/ksh
isql $DBPATH/ttlabs 2>/dev/null << !
unload to ln1_delemiter_Xs delimiter "XXXXXXXXXXXXX"
select request,invoice_centre
from rq
where invoice_centre is not null!
sed "s/XXXXXXXXXXXXX/\\\\t/g; w ln1_delemiter_tabs" ln1_delemiter_Xs exit
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of
Jim Chen
Sent: Tuesday, 15 March 2011 2:19 p.m.
To: ids@iiug.org
Subject: RE: Use of tab delimiter in ISQL [23084]
Have you tried delimiter "<tab key>"(with quotes)?
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of
Long Nguyen
Sent: Tuesday, 15 March 2011 12:12 PM
To: ids@iiug.org
Subject: Use of tab delimiter in ISQL [23083]
Hi all,
I am suddenly stuck when trying to use TAB as a delimiter in an unload
statement embedded in a unix script:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/ksh
isql $DBPATH/ttlabs 2>/dev/null << !
unload to ln1_delemiter_tab delimiter "want- to -use- tab-as-delimiter"
select request,invoice_centre
from rq
where invoice_centre is not null!
exit
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
So far I am just used to ";" or | as default delimiter.
I tried ascii9 and the "Tab" key but could not get the right result.
I don't want to use awk (OFS="\\\\t") to implement this, thinking the
simple way to create a file with Tab as delimiter after the SQL is
executed.
Any hint would be highly appreciated.
Env: Informix SE, ISQL 7.3.
Truly yours,
Long Nguyen
************************************************************************
*******
Forum Note: Use "Reply" to post a response in the discussion forum.
***************************************************************
This message is intended for the addressee named and may contain
confidential information. If you are not the intended recipient, please
delete it and notify the sender. Views expressed in this message are
those of the individual sender, and are not necessarily the views of the
Land and Property Management Authority. This email message has been
swept by MIMEsweeper for the presence of computer viruses.
***************************************************************
Please consider the environment before printing this email.
************************************************************************
*******
Forum Note: Use "Reply" to post a response in the discussion forum.
DISCLAIMER
This email contains information that is confidential and which may be
legally privileged. If you have received this email in error, please
notify the sender immediately and delete the email. This email is
intended solely for the use of the intended recipient and you may not
use or disclose this email in any way.
************************************************************************
*******
Forum Note: Use "Reply" to post a response in the discussion forum.
************************************************************************
*******
Forum Note: Use "Reply" to post a response in the discussion forum.