TIBSQL 
 V 1.01   2003.11.09.

Content

  1. Overview, License 
  2. The TIBSQLDLL.pas interface unit
  3. Use in DELPHI programs
  4. Data storage
  5. Make the TIBSQL.DLL
  6. Make the DEMO application
  7. Version info

  TIBSQL supported SQL language          



1.Overview, License

The TIBSQL a nativ, single users SQL system for Delpi progrms without use BDE. It support a subset of the standard  SQL language. ( TIBSQL language ). The TIBSQL not use indexes, load the full tables into memory. The TIBSQL wrote in  Delphi4.

If a application use  TIBSQL  must be two DLL file::

           TIBSQL.DLL,  BORLANDMM.DLL


The BORLANDMM.DLL is in Borland delphi system, licence is in delphi sytem too.

TIBSQL LICENSE
This software is freeware. You may use it for your commercial
software or for your own use. You may not sell these components
as is or with some changes.

LIMITED WARRANTY AND DISCLAIMER
No warranties are given to you. All your possible demands
will be disclaimed.

LIMITATION OF LIABILITY
No liabilities are given to you. All your possible demands
will be disclaimed.

The  TIBSQL  wrote in delphi4, tested it in delphi7 too.

 

Author::  Tibor Fogler    RoBIT Bt   (http://www.robitbt.hu    E-mail: foglert@robitbt.hu)


2. The TIBSQLDLL.pas interface unit

//TIBSQLError code
const
TIBSQL_OK = 0;
TIBSQL_ValueDbError = 3;
TIBSQL_NoResult = 4;
TIBSQL_TableNotFound = 5;
TIBSQL_OddQuote  = 6; 
TIBSQL_SQLsyntaxerror = 7;  
TIBSQL_OddBracket = 8;   l
TIBSQL_UnionError = 9;
// expressin errors
TIBSQL_ExprError = 10;
TIBSQL_ColumnNotFound = 11;
TIBSQL_ZeroDivide = 12;
TIBSQL_OtherExprError = 19;
// Parser Errors                               
TIBSQL_ParseError1 = 31;
TIBSQL_ParseError2 = 32;
TIBSQL_ParseError3 = 33;
TIBSQL_ParsesyntaxError = 39;

type
  TTIBSQLHandler = Pointer;  // TIBSQL handler
  TTIBSQLCursor = Pointer;   // TIBSQL Cursorr

var

// -----------------------------------------------------------------------------
// Simple rutins
// -----------------------------------------------------------------------------
TIBSQLconnect:  Function (DBPath, DBname : String) : TTIBSQLHandler;
TIBSQLDisconnect:  Procedure (var DBH : TTIBSQLHandler);
TIBSQLExecSQL:  Function (DBH : TTIBSQLHandler; SQLstr : String) : TTIBSQLCursor;
TIBSQLgettablenames:  Function (DBH : TTIBSQLHandler) : Tstrings;
// ------------------------------------------------------------------------------
// Cursor handle rutins
// ------------------------------------------------------------------------------
TIBSQLRecordCount:  Function (DBC : TTIBSQLCursor) : Integer;
TIBSQLColumnCount:  Function (DBC : TTIBSQLCursor) : Integer;
TIBSQLGo:  Procedure (DBC : TTIBSQLCursor; RecNo : Integer);
TIBSQLgetColumnType:  Function (DBC : TTIBSQLCursor; ColumnNo : Integer): String;
TIBSQLgetColumnName:  Function (DBC : TTIBSQLCursor; ColumnNo : Integer): String;
TIBSQLgetColumnSize:  Function (DBC : TTIBSQLCursor; ColumnNo : Integer): Integer;
TIBSQLgetString:  Function (DBC : TTIBSQLCursor; ColumnNo : Integer): String;
TIBSQLgetInteger:  Function (DBC : TTIBSQLCursor; ColumnNo : Integer): Integer;
TIBSQLgetFloat:  Function (DBC : TTIBSQLCursor; ColumnNo : Integer): Double;
TIBSQLgetDate:  Function (DBC : TTIBSQLCursor; ColumnNo : Integer): TDateTime;
TIBSQLgetLogical:  Function (DBC : TTIBSQLCursor; ColumnNo : Integer): Boolean;
TIBSQLCloseCursor:  Procedure (var DBC : TTIBSQLCursor);
// -----------------------------------------------------------------------
// Error handle rutins
// -----------------------------------------------------------------------
TIBSQLgetStatus:  Function (DBH : TTIBSQLHandler) : Integer;
TIBSQLgetErrorInfo:  Function (DBH : TTIBSQLHandler) : String;
Function TIBSQLgetErrormsg : String; // Error message in Hungarian

// Dll loading

Procedure TIBSQLLoadDll;


In the application's  dpr file, in  USES  section then first unit must be the "ShareMem"


3. Use in DELPHI programs

   Use the TIBSQL::

   

uses .....TIBSQLDLL,......

   1. TIBSQLLoadDll;
   2. TIBSQLHandle := TIBSQLconnect('dbpathr','dbname');
      3.  TIBSQLCursor := TIBSQLExecSQL(TIBSQLHandle, 'SQLstr');
      4.  if TIBSQLgetStatus = TIBSQL_OK then
             Result table handle by TIBSQLCursor
          else
             Error message
      5.  TIBSQLCursorClose(TIBSQLCursor);
      ..... repeat the  3,4,5 steps 
   6. TIBSQLDisconnect(TIBSQLHandle);

   After the  TIBSQLExecSQL always must be call the TIBSQLCloseCursor.

  Handle the result table:

   for i := 0 to TIBSQLRecordCount(TIBSQLCursor) - 1 do
     begin
       TIBSQLgo(TIBSQLCursor, i);
       for j := 0 to TIBSQLColumnCount(TIBSQLCursor) - 1 do
         handle data of Columns call the
         TIBSQLgetColumnName(TIBSQLCursor,j)
         TIBSQLgetColumnType(TIBSQLCursor,j)
         TIBSQLgetColumnSize(TIBSQLCursor,j)
         TIBSQLgetString(TIBSQLCursor,j)
         TIBSQLgetInteger(TIBSQLCursor,j)
         TIBSQLgetFloat(TIBSQLCursor,j)
         TIBSQLgetDate(TIBSQLCursor,j)
         TIBSQLgetBoolean(TIBSQLCursor,j)    .
     end;

   The INSERT, UPDATE, DELETE SQL statements work in memory, Write into the disk the next FLUSH, COMMIT, END TRANSACTION, START TRANSACTION sql statements, or the call disconnect.


4. Data storage

A database is a subdirectory in the "DBPath". (DBPath set in the TIBSQLConnect)

A table is a CSV file in the  "DBPath\DBname" directory.

The records are in the files standart delimeted string

The 1. record store the column names,
the 2. record store the column types,
the 3. record store the data size (in the memory format),
the next records store the data.


5. Make TIBSQL.DLL file

   Open the TIBSQLDLL.DPR in Delphi, and Build it..


6. Make the DEMO application

   Open the TIBSQLDLL_DEMO.DPR in Delphi, and Build it..


7. Version info

   V 1.00    2003.10.13


 

   V 1.01 Remove alias from column names 2003.11.09


 


 

  Budapest 2003.10.13.   Fogler Tibor

   www.robitbt.hu
   foglert@robitbt.hu