How to drop firebird database?

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
ssprano
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 20.08.2013, 10:35

How to drop firebird database?

Post 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
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: How to drop firebird database?

Post 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
ssprano
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 20.08.2013, 10:35

Re: How to drop firebird database?

Post 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
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Re: How to drop firebird database?

Post 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
Image
Post Reply