load / unload
Posted in 2000
Topics: SQL Development & Query Writing, Migration, Import/Export & Data Conversion
I've got an ftp push/pull feed with files, and I need a way to set a cron job to be able to run a load and unload statement once a day. The cron job isn't my problem, it's passing the sql statement to the database via commandline. I need to pass something like load from 012600am.customer insert into customer and then run unload to 012600am.out via a crontab entry, so a program to submit a sql query to a database from command-line is all I really need. Thanks, Alec Sent via Deja.com http://www.deja.com/ Before you buy.
In the cron, set up the Informix required environment vars then:
dbaccess databasename - <EOF
load from filename insert into tablename;EOF
Art S. Kagel
biggiealec@my-deja.com wrote:
> I've got an ftp push/pull feed with files, and I need a way to set a
> cron job to be able to run a load and unload statement once a day. The
> cron job isn't my problem, it's passing the sql statement to the
> database via commandline. I need to pass something like load from
> 012600am.customer insert into customer and then run unload to
> 012600am.out via a crontab entry, so a program to submit a sql query to
> a database from command-line is all I really need.
>
> Thanks,
>
> Alec
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
First of all, create a special directory for this job.
Create a command file to call from your cron.
Create a sql body file for the up & donw load
unlcmd = Unload To FILENAME Select * from customers
uplcmd = Load From FILENAME Insert Into customers
The Cron command file should look something like this:
#1e setup de env to connect to your database
#As it's looks you first need a file name
#So put something in cron file like:
date +%d%h > name
#Now make a sql command complete
cat unlcmd | sed s/FILENAME/`cat name`.unl/ > unlcmd.sql
cat uplcmd | sed s/FILENAME/`cat name`.unl/ > uplcmd.sql
# Start the work
dbaccess databsename unlcmd.sql
dbaccess otherdatabase uplcmd.sql
etc...
bibi
Arthur
In article <86nqor$e0$1@nnrp1.deja.com>,
biggiealec@my-deja.com wrote:
> I've got an ftp push/pull feed with files, and I need a way to set a
> cron job to be able to run a load and unload statement once a day.
The
> cron job isn't my problem, it's passing the sql statement to the
> database via commandline. I need to pass something like load from
> 012600am.customer insert into customer and then run unload to
> 012600am.out via a crontab entry, so a program to submit a sql query
to
> a database from command-line is all I really need.
>
> Thanks,
>
> Alec
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
"Art S. Kagel" wrote:
>
> In the cron, set up the Informix required environment vars then:
>
> dbaccess databasename - <EOF
LOCK TABLE tablename in EXCLUSIVE MODE;
> load from filename insert into tablename;> EOF
>
> Art S. Kagel
>
> biggiealec@my-deja.com wrote:
>
> > I've got an ftp push/pull feed with files, and I need a way to set a
> > cron job to be able to run a load and unload statement once a day. The
> > cron job isn't my problem, it's passing the sql statement to the
> > database via commandline. I need to pass something like load from
> > 012600am.customer insert into customer and then run unload to
> > 012600am.out via a crontab entry, so a program to submit a sql query to
> > a database from command-line is all I really need.
> >
> > Thanks,
> >
> > Alec
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.