Suppressing Column on SELECT
Posted in 2007
Paul asked how to stop dbaccess showing the "(expression)" column header for a query like SELECT trim(tabname) FROM systables. Replies gave several options: alias the expression (SELECT trim(tabname) AS tabname ...) to get a sensible name; use OUTPUT TO ... WITHOUT HEADINGS (to a file, to /dev/stdout, or OUTPUT TO PIPE 'cat') to drop headings entirely; use UNLOAD TO with a delimiter; filter dbaccess output with awk/grep; or use the IIUG tool SQLCMD, which avoids the headings altogether.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: SQL Development & Query Writing
Hi guys, How can i suppress the "(expression)" column from this SELECT statement: Select trim(tabname) from systables IDS 10 rgds Paul
PAUL GATHOGO schrieb:
> Hi guys,
>
> How can i suppress the "(expression)" column from this SELECT statement:
>
> Select trim(tabname) from systables
>
> IDS 10
>
> rgds
> Paul
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
to supress all part of the header (on unix)
OUTPUT TO PIPE 'cat'
WITHOUT HEADINGS
SELECT .........
To rename an expression use the alias names in the projection list.
This you can use to rename any column or expression or function like so:
[ if in the table testtable we have columns a, b and c ]
SELECT
a first_column
, b * c product
FROM testtable;
will give you 2 output columns per row, labeled
first_column and product.
HTH
dic_k
--
Richard Kofler
SOLID STATE EDV
Dienstleistungen GmbH
Vienna/Austria/Europe
You can name it something else:
Select trim(tabname) AS tabname from systables;
If you mean 'How can I get dbaccess to stop printing a column header for this
output?", try:
unload to 'outfile' delimiter ' 'Select trim(tabname) AS tabname from systables;
Art S. Kagel
----- Original Message -----
From: Paul Gathogo <ids@iiug.org>
At: 5/17 12:30:59
Hi guys,
How can i suppress the "(expression)" column from this SELECT statement:
Select trim(tabname) from systables
IDS 10
rgds
Paul
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
You can try following:
dbaccess <database name> - <<EOF 2>/dev/null | awk '{ printf("%s\\
",$2)}'
select trim(tabname) from systables;
EOF
-Sanjit Chakraborty
Hi, Two possible answers: 1. select trim(tabname) as table from systables; This replaces "(expression)" with "table". Its called an "alias" in the manuals. 2. output to "/tmp/queryoutput" without headings select trim(tabname) from systables; This puts the list in a file with no heading at all. There's no way to have the effect of option 2 without using a file to receive the query result. See the Guide to SQL:Syntax for all the details. Cheers, Dick Snoke IBM Software Group - ChannelWorks dsnoke@us.ibm.com (404) 487-1595 "PAUL GATHOGO" <pgathogo@gmail.com> Sent by: ids-bounces@iiug.org 05/17/2007 09:18 AM Please respond to ids@iiug.org To ids@iiug.org cc Subject Suppressing Column on SELECT [9175] Hi guys, How can i suppress the "(expression)" column from this SELECT statement: Select trim(tabname) from systables IDS 10 rgds Paul ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.
Hi,
You can try this:
dbaccess <database name> - <<EOF 2>/dev/null | grep -v -E '^$|expre|row'select
trim(tabname) from systables;EOF
Regards,
Cesar Cruz
> To: ids@iiug.org> From: pgathogo@gmail.com> Subject: Suppressing Column on
SELECT [9175]> Date: Thu, 17 May 2007 09:18:57 -0400> > Hi guys, > > How can i
suppress the "(expression)" column from this SELECT statement: > > Select
trim(tabname) from systables > > IDS 10 > > rgds > Paul > > >
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum. >
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces.
It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=
en-us
> "PAUL GATHOGO" <pgathogo@gmail.com> asked: > How can i suppress the "(expression)" column from this SELECT statement: > > Select trim(tabname) from systables > > IDS 10 and Richard Snoke <dsnoke@us.ibm.com> answered: > Two possible answers: > > 1. select trim(tabname) as table from systables; This replaces > "(expression)" with "table". Its called an "alias" in the manuals. > 2. output to "/tmp/queryoutput" without headings select trim(tabname) from > systables; This puts the list in a file with no heading at all. > > There's no way to have the effect of option 2 without using a file to > receive the query result. Most modern versions of Unix/Linux have /dev/stdout as a file - you could output to that. Another option is to use SQLCMD - it was written because once upon a couple of decades ago I got fed up with those headings (and with the variable format). See the IIUG Software Archive. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2007.0226 -- http://dbi.perl.org/ NB: Please do not use this email for correspondence. I don't necessarily read it every week, even.