?
Solved

Backing up SQL table at the end of month

Posted on 2004-04-20
5
Medium Priority
?
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
shaneholmes earned 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

770 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