123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- (******************************************************************************
- * *
- * (c) 2005 CNOC v.o.f. *
- * *
- * File: aListTables.pp *
- * Author: Joost van der Sluis ([email protected]) *
- * Description: SQLDB example and test program *
- * License: GPL *
- * *
- ******************************************************************************)
- program aListTables;
- {$mode objfpc}{$H+}
- uses
- Classes,
- sqldb, pqconnection, mysql4conn, IBConnection, ODBCConn,
- SqldbExampleUnit;
- var Tables : TStringList;
- i : integer;
- begin
- ReadIniFile;
- // create FConnection
- if dbtype = 'mysql' then Fconnection := tMySQLConnection.Create(nil);
- if dbtype = 'postgresql' then Fconnection := tpqConnection.Create(nil);
- if dbtype = 'interbase' then Fconnection := tIBConnection.Create(nil);
- if dbtype = 'odbc' then Fconnection := tODBCConnection.Create(nil);
- if not assigned(Fconnection) then ExitWithError('Invalid database-type, check if a valid database-type was provided in the file ''database.ini''');
- with Fconnection do
- begin
- DatabaseName := dbname;
- UserName := dbuser;
- Password := dbpassword;
- open;
- end;
- // create FTransaction
- Ftransaction := tsqltransaction.create(nil);
- with Ftransaction do
- begin
- database := Fconnection;
- StartTransaction;
- end;
- Fconnection.Transaction := Ftransaction;
- Tables := TStringList.Create;
- Fconnection.GetTableNames(Tables);
- for i := 0 to Tables.Count -1 do writeln(Tables[i]);
- Tables.Free;
- Ftransaction.Free;
- Fconnection.Free;
- end.
|