Subject ANN: Using IBExpert Functions inside your application
Author HKlemt
Using IBExpert Functions inside your application

******************************************************************
* Special Offer: IBEscript Distribution License only 99 Euro *
******************************************************************
* Special Price only valid until 15th Nov 2006 *
******************************************************************

IBEScript DLL allows you to integrate IBExpert scripts in your own
application, A simple Delphi example using the DLL can be found on

www.ibexpert.com/download/IBEScriptDll.zip

It can also be used from all other programming languages that can
handle DLL calls.

The IBEScript DLL Distribution License allows you to distribute
ibescript.dll together with your own software to your customers.
You may deploy ibescript.dll everywhere, where your own
software is installed.

The regular price for the IBEScript DLL Distribution License is
EUR 199.00 (plus sales tax/VAT at the current German rate of
16% for all EU residents). This includes all updates for the
following two months. To extend the update eligibility, it
is possible to upgrade to the IBExpert VAR License.

IBEScript DLL can be ordered in our online shop (simply
select the product group Distribution license).

The Distribution license includes the unlimited distribution right!
Buy once, use anywhere!
******************************************************************

******************************************************************
* Sonderangebot: IBEscript Distribution Lizenz nur 99 Euro *
******************************************************************
* Angebotspreis nur gültig bis zum 15.11.2006 *
******************************************************************

IBEScript DLL ermöglicht Ihnen die Integration von IBExpert
Scripts in Ihre eigene Anwendung. Ein einfaches Delphi
Beispiel mit dieser DLL finden Sie unter

www.ibexpert.com/download/IBEScriptDll.zip

Es kann auch von allen anderen Programmen genutzt werden, die DLL
Aufrufe verarbeiten können.

Die IBEScript DLL Vertriebslizenz ermöglicht es Ihnen, ibescript.dll
zusammen mit Ihrer eigenen Software zu vertreiben. So können Sie
ibescript.dll überall dort einsetzen, wo Sie Ihre eigene Software
installiert haben.

Der Listenpreis für die IBEScript DLL Vertriebslizenz beträgt
EUR 199.00 (für Deutschland und EU-Staaten zzgl. 16% Mwst),
inklusive aller Updates der folgenden zwei Monate. Um die
Update-Berechtigung zu verlängern, ist ein Upgrade auf die
IBExpert VAR-Lizenz möglich.

IBEScript DLL kann in unserem Online Shop bestellt werden (wählen
Sie einfach die Warengruppe Distribution license [Vertriebslizenz]).

Die Vertriebslizenz enthält das Recht zur unlimitierten Distribution!
Einmal kaufen, überall benutzen!
******************************************************************
Examples

you can use it for executing ibeblock scripts that connect to
different databases at the same time, integrate any odbc
connection as source or destination, simple data import
and export, metadata comparison and much more.

For using the distribution license, no keys are needed.
You do not even need ibexpert full version, but the
integrated debugger will help you to develop working
scripts. The distribution license contains only the
file ibescript.exe and the unlimited right
to distribute it together with your software.

What is an IBEBLOCK?

It is a set of DDL, DML and other statements that are executed
on the server and on the client side, and which include some
specific constructions applicable only in IBExpert or
IBEScript (excluding the free versions of these products),
independent of the database server version.

With EXECUTE IBEBLOCK you will be able to:

* Work with different connections within the single IBEBLOCK at
the same time.
* Move (copy) data from one database to another.
* Join tables from different databases.
* Compare data from different databases and synchronize them.
* Populate a table with test data using random values or values
from other tables or even from other databases or ODBC
Connections.
* ... and much more.

The syntax of IBEBLOCK is similar to that of stored procedures
but there are many important extensions. For example:

* You can use EXECUTE STATEMENT with any server, including
InterBase 5.x, 6.x, 7.x. 2007
* You can use one-dimensional arrays (lists) of untyped variables
and access them by index.
* It isn't necessary to declare variables before using them.
* You can use data sets (temporary memory tables) to store data.
* ... and much more.


Simple ibeblock example to copy data between two databases incl blobs

execute ibeblock
as
begin
create connection src dbname 'localhost:c:\src.fdb'
password 'repl' user 'REPL' clientlib 'fbclient.dll';

create connection dest dbname 'localhost:c:\dest.fdb'
password 'repl' user 'REPL' clientlib 'fbclient.dll';

use src;
for select id, usr, ts, sql, idx, dat
from ibe$log
into :id, :usr, :ts, :sql, :idx, :dat
do
begin
use dest;
insert into ibe$log(id, usr, ts, sql, idx, dat)
values (:id, :usr, :ts, :sql, :idx, :dat);
end

use dest;
commit;
close connection src;
close connection dest;
end


Simple example to copy data from ib/fb to MS Access using odbc

execute ibeblock
as
begin
FBCon =
ibec_CreateConnection(__ctFirebird,'DBName=LOCALHOST:C:\DB1.FDB;
ClientLib=fbclient.dll; user=SYSDBA; password=masterkey;
names=ISO8859_1; sqldialect=3');

OdbcCon = ibec_CreateConnection(__ctODBC, 'DBQ=C:\msadb.mdb;
DRIVER=Microsoft Access Driver (*.mdb)');

USE FBCon;
FOR
SELECT F1, F2, F3
FROM TBL
INTO :F1,:F2,:F3
do
BEGIN
USE OdbcCon;
INSERT INTO TBL(F1,F2,F3)
VALUES(F1,F2,F3);

END
ibec_CloseConnection(OdbcCon);
ibec_CloseConnection(FBCon);
end



You can execute single IBEBLOCKs via the SQL Editor. You can
debug them in the SQL Editor too. They are debugged in the same
way as stored procedures and triggers. Also you can include
IBEBLOCKs into your scripts and execute these scripts as
usual - using the Script Executive or IBEScript.exe.


more Examples usable in IBEscript.dll can be found here
http://www.ibexpert.info/documentation/20297.html

Here are a few examples illustrating the usage of
EXECUTE IBEBLOCK (please refer to the individual
subjects for details):

* Automatic script execution
* ODBC Access
* Extract Metadata using IBEBlock
* Comparing databases using IBEBlock
* Comparing scripts with IBEBlock
* Data Comparer using cursors
* Test data generator
* Joining tables from different databases
* Recreating indices #1
* Recreating indices #2
* Building an OLAP cube
* Inserting files into a database
* Inserting data from a file into a database
* Importing data from a CSV-file
* Importing data from file
* Export data into DBF
* Creating script from Database Designer model file
* Creating an UPDATE-script with domain descriptions
* IBEBlock User Forms
* Daily backup of IBExpert User Database
* Disable and Enable IBExpert features

All scripts, demos etc. can be downloaded from
http://www.ibexpert.com/download/ (save
ibeblockex.zip to the hard drive and extract).


The IBExpert Team

Any questions? Ask register@...

The most Expert for InterBase and Firebird --- www.ibexpert.com
HK Software - Gerhard Stalling Str 47A - 26135 Oldenburg - Germany
Phone/Fax +49 700 IBEXPERT (42397378) www.h-k.de