Page 1 of 1

How to drop firebird database?

Posted: 20.08.2013, 10:54
by ssprano
Dear all,

I use Delphi 7 with Zeos DBO 6.6 and I need to drop firebird databases from inside a program.
How can I do it? I have tried using TZConnection.ExecuteDirect('DROP DATABASE') but there is always an error saying 'Token not recognized'. I have also tried using TZSQLProcessor and TZQuery.SQL but the same happened.
Does someone have a solution?

Thanks in advance,
SS Prano

Re: How to drop firebird database?

Posted: 21.08.2013, 08:08
by marsupilami
Hello SS Prano,

I am not sure, wether this scenario is supported by Zeos at all. But if the database is on the same computer as your program you could simply try to delete the file. But if you want to, you could take a look at the database creation code in Zeos 6 and do soemthing similar for dropping a database remotely.
Best regards,

Jan

Re: How to drop firebird database?

Posted: 21.08.2013, 11:25
by ssprano
Dear marsupilami,

Thanks for your suggestion. In my case, the database is remote so I can not just delete the file
As far as I know, Zeos doesn't have a method to create nor drop a database.
In fact from a ZEOS tutorial I found, we can create database by using codes similar to :

ZConnection1.Database := 'temp.fdb';
ZConnection1.Protocol := 'firebird-2.1';
ZConnection1.Properties.Add('CreateNewDatabase=CREATE DATABASE ''temp.fdb'' USER ''SYSDBA'' PASSWORD ''masterkey''');
ZConnection1.Connect;

But when I tried using codes similar to :
ZConnection1.Properties.Add('DropDatabase=DROP DATABASE');
ZConnection1.Connect;

nothing happened, the database is still there.

Best regards,
SS Prano

Re: How to drop firebird database?

Posted: 21.08.2013, 14:07
by mdaems
Hi ssprano,

Marsipulami didn't want to say "The functionality is already available in zeoslib". He said : have a look at the zeoslib code.
He didn't specify where, but it's here : TZInterbase6Connection.Open in ZDbcInterbase6.pas.
Basically it executes the statement using the API connection object instead of a API statement object. A quick google lookup gives me the impression this can also work for the DROP command.
I don't have any plans to provide this support as a zeoslib feature. Actually the create statement already is a hack for FB only. And maybe you could try this:

Code: Select all

ZConnection1.Properties.Add('CreateNewDatabase=DROP DATABASE XXXX');
Because of the way this hack was implemented it just might work.

Mark