Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Backup job
Sat, Nov 29 2008 2:10 PMPermanent Link

Leslie
Hi,

What is wrong with the syntax of this  job?

BEGIN
declare Target varchar;    
set Target = 'DBName Backup On' + Cast(CURRENT_TIMESTAMP as Varchar)+ '.Bkp';

BACKUP  /* Error #700 ... but  instead found DATABASE --->*/   DATABASE DBName
AS Target
TO STORE "Backup"
COMPRESSION 9
INCLUDE CATALOG;   

END


Regards,
Lelsie
Sun, Nov 30 2008 7:31 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Leslie,

The problem is that BACKUP is not a PSM statement, so it must be
executed as dynamic SQL from inside the job, for example:

BEGIN
  DECLARE Target VARCHAR;

  SET Target = 'DBName Backup On '+CAST(CURRENT_DATE AS VARCHAR);
  EXECUTE IMMEDIATE '
    BACKUP DATABASE AGV2Afm2009
    AS "'+Target+'"
    TO STORE "Backup"
    COMPRESSION 9
    INCLUDE CATALOG; ';
END

Also, if you use CURRENT_TIMESTAMP to generate the backup name you will
end up with an invalid filename for the backup because of the separator
characters in the time part. You should also remove '.bkp' from the name
because EDB will automatically append the extension for the backup file.

--
Fernando Dias
[Team Elevate]
Sun, Nov 30 2008 8:16 AMPermanent Link

Leslie
Thank you very much Fernando!
Image