Re: Urgent
Posted in 2000
"COOPER, Joseph" wrote:
>
> Create a shell script along the lines of
>
> !/bin/ksh
>
> dbaccess joe - <<-EOF
> unload to "/tmp/joe1" delimiter "|"
> select count(*), sum(tabid) from systables;
> unload to "/tmp/joe2"
> select * from tab1;> EOF
>
> cat /tmp/joe1 /tmp/joe2 /tmp/joe1 > /tmp/joefin
>
> echo "Done"
>
> Unfortunately I din't have the employee table at
> hand so you'll have to do some work :)
>
> > > > From: "Sarah Jessica" <sarah_jessica@hotmail.com>
> > > > >
> > > > >I am unloading the data into the test.dat. How can I
> > have the header
> > >and
> > > > >trailer that having the record count and the total amount.
> > > > >
> > > > >The Employee table is like this:
> > > > >eno smallint
> > > > >ename char(20)
> > > > >amount money(14,2)
Isn't this all getting rather complicated? How about:
UNLOAD TO "/home/sarah/test.dat"
SELECT eno, ename, amount
FROM employee
UNION ALL
SELECT COUNT(*), "TOTAL", SUM(amount)
FROM employee
You might need to convert eno to a dec with something like ROUND(), if
the data types are not quite right. Or put the total in the header.
Cheers,
--
Mark.
+----------------------------------------------------------+-----------+
| Mark D. Stock mailto:mdstock@mydas.freeserve.co.uk |//////// /|
| http://www.informix.com http://www.informixhandbook.com |///// / //|
| http://www.iiug.org +-----------------------------------+//// / ///|
| |What year 2000 bug? year 2000 bug? |/// / ////|
| |year 2000 bug? year 2000 bug? year |// / /////|
| |2000 bug? year 2000 bug? year 1900 |/ ////////|
+----------------------+-----------------------------------+-----------+