Computing.Net > Forums > Unix > unix shell script to unload data

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

unix shell script to unload data

Reply to Message Icon

Name: temmy
Date: March 17, 2009 at 03:26:46 Pacific
OS: Unix
Product: Ibm Aix
Subcategory: General
Comment:

Hi, am trying to write unix script to pull large data from my informix database and schedule time for it(every morning) and save it as an excel file in a folder name daily_report.

this my SQL statement

unload to suspend101_20090110
select usertype, count(msisdn)
from basetab
where AccountState!=3 and CallServiceStop<'20090110'
and PreAccountStop<'20090110' and AccountStop>='20090110'
group by usertype
order by 1;

br

temmy



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 17, 2009 at 07:38:59 Pacific
Reply:

On the Unix side, this korn shell script, will execute your SQL: Unforutunately, I don't know a way of informix creating an Excel spreadsheet. I think you're left with moving the text file to Window's and pulling the file into Excel.

#!/bin/ksh

# set to your database nameDBNAME="mydatabasename";
export DBNAME
# use dbaccess or isqlINTERFACE_CMD="dbaccess";
export INTERFACE_CMD

# send to standard output
DBCOMMAND="$INTERFACE_CMD -e $DBNAME";
export DBCOMMAND

engine_up=$(onstat - | grep "Up" | wc -l)

if [ $engine_up -eq 0 ]
then
echo "Informix Engine must be Up to execute commands."
exit
fi

# untested
$DBCOMMAND << MSG
unload to suspend101_20090110
select usertype, count(msisdn)
from basetab
where AccountState!=3 and CallServiceStop<'20090110'
and PreAccountStop<'20090110' and AccountStop>='20090110'
group by usertype
order by 1;
MSG


0
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: unix shell script to unload data

Unix shell script and Oracle data www.computing.net/answers/unix/unix-shell-script-and-oracle-data/5298.html

Unix Shell Script www.computing.net/answers/unix/unix-shell-script/3580.html

email via shell scripting www.computing.net/answers/unix/email-via-shell-scripting/5956.html