How do I dump progress databse?

mathew

New Member
Hi,

I would like to dump some table data's from a progress database to a text file. I am really a beginner. For this, I have two problems:
1. How do I create a procedure that extracts table data from a table?
2. How do I run this automatically on everynight?

Thanks,
Mathew
 

taqvia

Member
There are different ways to dump progress database. Since you want it to run as a cron job everynight dictionary dump will not be useful.

You can run the below snippet to get the dump of datbases everynight.

#!/bin/sh
# ars2 is the list of tables that needs to be dumped.
table=ars2
cat ${table} |
while read file
do
if [ -f $file.p ]
then
rm /export/$file.p
fi
echo "/* This is an auto generated Code Please do not edit Arshad */ " >>/export/$file.p
echo " def var outputfile as char init '$file.txt' . " >>/export/$file.p
echo " def var i as int no-undo . " >> /export/$file.p
#echo " output to \""$file".txt \" . " >>/export/$file.p
echo " for each $file no-lock: " >>/export/$file.p
echo "/* 2 Gb limit if if reaches switch the output to new file */ " >>/export/$file.p
echo " file-info:file-name = outputfile . " >> /export/$file.p
echo " if file-info:file-size > 2040109465 then do : " >>/export/$file.p
echo " i = i + 1 . " >> /export/$file.p
echo " outputfile = outputfile + string(i) . " >>/export/$file.p
echo " end . " >>/export/$file.p
#echo " export $file . " >>/export/$file.p
echo " run export-file . " >>/export/$file.p
echo " end . " >>/export/$file.p
echo "\n\n\n" >> /export/$file.p
echo " procedure export-file . " >>/export/$file.p
echo " output to value(outputfile) append . " >>/export/$file.p
echo " export $file . " >>/export/$file.p
#echo " end . " >>/export/$file.p
echo " end . " >>/export/$file.p
# run the code in background
bpro -db /export/data/xxxxx -RO -p $file.p >>/tmp/${file}.log
done


Note: I hope that you are on unix flavour else you can write the windows equivalent and place it in scheduler.
you can also delete the dump record everyday by another snippet once your purpose is served..


Arshad
 

pietervdm

New Member
Hi Mathew

If you want to dump data to load it back into another Progress database there are other ways of dumping the data, but if you want to dump the data to a text file so you can use it somewhere else the easiest way will be:

Create a file in vi or notepad:

OUTPUT TO c:\myfile.txt.

FOR EACH MyTable NO-LOCK:
EXPORT MyTable.
END.

OUTPUT CLOSE.

Thats it. Save the file.

Then you can scedule the following command:
$DLC/bin/_progres -db yourdbname -b -p path_to_your_saved_file

For more control of the layout you can do:

OUTPUT TO c:\myfile.txt.

FOR EACH MyTable NO-LOCK:
PUT UNFORMATTED
MyTable.Field1 ","
MyTable.Field2 "," SKIP.
END.

OUTPUT CLOSE.

Hope it helps
Pieter
 
Top