Help with Table export and backups...
Posted in 1999
Topics: Stored Procedures & SPL, Migration, Import/Export & Data Conversion
Hi All, I would really appreciate your help on this problem that I have. I need to create a script that will export tables to delimited text files on a disk at regular intervals. My problems are these: 1). I assume that UNLOAD will do this for me but how can I pass it a file name to use to export the data to? 2). Can I write a stored procedure that I can run from the command line that can take as parameters things like a filename, directory to store it in, and number of records to export? I have never really done anything like this before and any help woulr be much appreciated, Thanks.
While I can't remember exactly how to do it this might help.
dbaccess can run SQL form the command line. You could use that.
Hope that helps.
Jack Murphy <jmurphy@fore.com> wrote in message
news:7lvgik$hj5$1@shell.fore.com...
> Hi All,
>
> I would really appreciate your help on this problem that I have.
>
> I need to create a script that will export tables to delimited text files
on
> a disk at regular intervals.
>
> My problems are these:
> 1). I assume that UNLOAD will do this for me but how can I pass it a file
> name to use to export the data to?
>
> 2). Can I write a stored procedure that I can run from the command line
that
> can take as parameters things like a filename, directory to store it in,
and
> number of records to export?
>
> I have never really done anything like this before and any help woulr be
> much appreciated,
>
> Thanks.
>
>
>
Hi Jack,
If I understood your question, you want to make a script/program or
something like that that exports data from a table to a ASCII file. What
you could do is the following:
Make a script which looks like this:
------------------------------------------------------------------
#!/bin/ksh
DBNAME=${1}
TABNAME=${2}
ASCII_FILE=${3}
dbaccess ${DBNAME} 1>/dev/null 2>&1 <<EOF
UNLOAD TO "${ASCII_FILE}" DELIMITER "#"
SELECT * FROM ${TABNAME}
EOF
-----------------------------------------------------------------------
This script should do the job.
Greetings,
Rob Prop
Hi All,
Sorry,I should have stated platform. We are trying to do this on NT and the
problem is that we cannot install a Unix shell...
Thanks,
J.
Rob Prop <rprop@concepts.nl> wrote in message
news:3783A060.5BD32B58@concepts.nl...
> Hi Jack,
>
> If I understood your question, you want to make a script/program or
> something like that that exports data from a table to a ASCII file. What
> you could do is the following:
>
> Make a script which looks like this:
>
> ------------------------------------------------------------------
>
> #!/bin/ksh
>
> DBNAME=${1}
> TABNAME=${2}
> ASCII_FILE=${3}
>
> dbaccess ${DBNAME} 1>/dev/null 2>&1 <<EOF
>
> UNLOAD TO "${ASCII_FILE}" DELIMITER "#"
> SELECT * FROM ${TABNAME}>
> EOF
>
> -----------------------------------------------------------------------
>
> This script should do the job.
>
> Greetings,
>
> Rob Prop
>