Solved

Backing up SQL table at the end of month

Posted on 2004-04-20
5
141 Views
Last Modified: 2012-02-29
Hi All,
      I need to backup a table in an sqlite database and I want to do this at the end every month. How would I get delphi to check it is the end of the month and back up the table (ie DUMP data_backup).
0
Comment
Question by:lloydie-t
  • 2
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
shaneholmes earned 125 total points
ID: 10873624
Here is a link to backuping up SQL database or tables

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20691981.html?query=sql+backup&searchType=topic


here is a function to test for End Of Month:

Function Eom(Dt:TDateTime):Boolean;
VAR Y,M,D:Word;
Begin
  DecodeDate(Dt,Y,M,D);
  D := 1;
  Inc(M);
  If M > 12 then
    Begin
    Inc(Y);
    M := 1
    End;
Result := Trunc(Dt) = Trunc(EncodeDate(Y,M,D)-1);  
End;

example

if EOM then
begin
 //run backup query here
end;

Hope this helps!

SHane
0
 

Author Comment

by:lloydie-t
ID: 10873690
Hi shane,
            that looks great. Does the above code automaically test for end of the month. If not how would I? Some sort of timer?
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10873927
You need to call it as i described above - like this

if EOM then
begin
 //run backup query here
end;

You could use a timer to test the time, if its a certain time of day say 1:00 pm,
test for EOM

set the interval for 60000 - to test every minute (or whatever you like)


Shane

0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10876704

   make it in stand alone excutable and put it in scheduled task for Windows or in cron daemon for Unix/Linux. Your application should be aware of the backup routines ....
0
 

Author Comment

by:lloydie-t
ID: 10876756
Ivanov, I had thought of that, but I need to stop some processes in the main application before backing up the database. So therefore I prefered to do the backup in the main application.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now