Solved

Backing up SQL table at the end of month

Posted on 2004-04-20
5
144 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTML text in the body of an email (delphi code) 12 118
Making delphi communicate with a c# service 16 103
Firemonkey DbLookupComboBox equivalent ? 2 47
RESTRequest Parameter 4 31
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

778 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