Solved

Backing up SQL table at the end of month

Posted on 2004-04-20
5
138 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility

   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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

7 Experts available now in Live!

Get 1:1 Help Now