Jumat, 25 Januari 2008

FBCopy 1.7 released (FB tool)

FBCopy version 1.7 is released. FBCopy is a tool for Firebird. What this tool does? According to it's readme file, this tool is for copy data between Firebird tables and databases. FBCopy is a command-line tool, so you can use it inside batch scripts, cron jobs, etc. Currently, Linux and Windows versions are available.

The capabilities are:
* copying data between databases (sorted by dependency tree)
* copying generator values (since version 1.70)
* comparing table fields
* comparing data (with detailed output in HTML)
* open source under MIT license
* cross platform - works on Windows and Linux
* works with all Firebird versions (tested 1.0 - 2.1)
* easy to integrate into batch jobs
* light for remote use via SSH

You can download this nice tool in here

Rabu, 23 Januari 2008

New Little Feature in Zeos

Hi, there are 2 new methods on TZConnection component, they are:

function ExecuteDirect(SQL : String) : boolean;
function ExecuteDirect(SQL:string; var RowsAffected:integer):boolean;

That methods are to execute SQL DDL statement directly without need of TZQuery.
You can try and test this new feature in the Zeos testing Rev337. If the method not act correctly, you can tell us in the forum.

Firebird Roadmap 2008

The Firebird project already release the FB 2.1 RC1 (vailable for field testing on 64-bit and 32-bit Windows and Linux (MacOSX to follow soon)) and also their roadmap in 2008.

Kamis, 17 Januari 2008

BLOB Field using ZeosDBO 6.6.x

Hi, I want to share how to save and load BLOB from database. The database I use here is Firebird, but I think Zeos behaviour is same. This example below is to save and load the JPEG image into and from Firebird database. If you use bitmap image then you can display it using TDBImage, but for JPEG you cann't do that otherwise you get an error that said that it is not a valid bitmap. So in this code, for display the image from database I use TDBImage with no binding (the datasource property still null). So let's look the code:

The component that I dropped:

uses jpeg, ........
TForm1 = class(TForm)
con1: TZConnection;
qr1: TZQuery;
qr1aaa: TStringField; //persistant field that only string value
qr1gambar: TBlobField; //persistent field "gambar" that used to save JPEG image
ds1: TDataSource;
dlgOpen1: TOpenDialog;
dbnvgr1: TDBNavigator;
dbeaaa: TDBEdit; //use binding to connect to field "aaa"
btn1: TButton;
btn2: TButton;
dbimg1: TDBImage;
procedure btn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btn2Click(Sender: TObject);
{ Private declarations }
{ Public declarations }

The code:

procedure TForm1.FormShow(Sender: TObject);
//Connect to Database and open query

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
//Close query and connection

procedure TForm1.btn1Click(Sender: TObject);
if dlgOpen1.Execute then
//Load JPEG image (or anything type of file) into database

procedure TForm1.btn2Click(Sender: TObject);
var j:TJPEGImage;
//Display image from database to TDBimage (dbimg1) component

How the code work?
"btn1Click" method is clicked after the dataset is in edit or insert mode, then after it load from file then post it (I use DBNavigator in the above example). And then "btn2Click" is for display image from database to TDBImage component. Simply enough? yes, that's all.

Now, what about other format like Word, Excel or PDF document that you want to extract from the database? (the save method is same). The answer is, save it to file again. Zeos already implement it well, so you can do like this:


Also simply enough? yes. So don't worry to use BLOB field with Zeos component :)
How about to save/load it from Stream? You can also use "SaveToStream" and "LoadFromStream" method.