RE: SELECT x columns
Posted in 1999
How about building the script on the fly? Something like
COLLIST=`dbaccess $CURDB <<EOF 2>/dev/null
output to pipe 'cat' without headings
select colname, colno
from systables a, syscolumns b
where tabname = "$TAB"
and a.tabid = b.tabid
order by 2EOF
`
# put the columns to ignore in EXCLUDE (or have the file a permanent one)
echo $EXCLUDE | tr ',' ' ' |
nawk '{for (i = 1; i <= NF; i++) print "^" $i "$"}' >/tmp/$$.grep
COLLIST=`echo $COLLIST | nawk '{for (i = 1; i <= NF;i += 2) print $i}' |
grep -v -f /tmp/$$.grep |
nawk '{ if (length(Sel) ) Sel = Sel "," $1; else Sel = $1 }
END {print Sel}'`
dbaccess $CURDB <<EOF
SELECT $COLLIST
FROM {etc. . .}
It's ugly, and I'm sure could be done much more cleanly in Perl, but I'm
still
on the kiddie slopes there
> -----Original Message-----
> From: 1900live@my-deja.com [SMTP:1900live@my-deja.com]
> Sent: Tuesday, October 05, 1999 1:16 AM
> To: informix-list@iiug.org
> Subject: SELECT x columns
>
> Is it possible to select all column except one without typing each
> column name ?
>
> We have a table with about 30 columns in it and I want to get all except
> the first one. I don't want have to rely on a pretyped script
> explicitly stating all columns as we sometimes have a need to add extra
> columns.
>
> I know I can list the column from syscolumns and match the tabid with
> that from systables but I need to format the select for the columns so
> it comes back as 1 row not a row per column.
>
> Any help / ideas appreciated.
>
> Brian
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.