You've already forked lazarus-ccr
TvPlanIt: Extended ZEOS datastore sample to show usage of a Firebird database.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8254 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -124,6 +124,12 @@ begin
|
||||
if Assigned(FConnection) then
|
||||
begin
|
||||
protocol := Lowercase(FConnection.Protocol);
|
||||
if protocol = 'firebird' then
|
||||
begin
|
||||
FIdFieldTypeNameInSQL := 'INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY'; // This is for Firebird v3
|
||||
// FIdFieldTypeNameInSQL := 'INTEGER NOT NULL PRIMARY KEY'; // This might work for firebird v2.x
|
||||
FBoolFieldTypenameInSQL := 'BOOLEAN';
|
||||
end else
|
||||
if protocol = 'postgresql' then
|
||||
FIdFieldTypeNameInSQL := 'SERIAL NOT NULL PRIMARY KEY'
|
||||
else
|
||||
@@ -162,10 +168,17 @@ end;
|
||||
|
||||
procedure TVpZeosDatastore.CreateTable(const ATableName: String;
|
||||
CreateIndex: Boolean = true);
|
||||
var
|
||||
CREATE_TABLE: String;
|
||||
begin
|
||||
if (Lowercase(FConnection.Protocol) = 'firebird') then
|
||||
CREATE_TABLE := 'RECREATE TABLE ' // Not clear if this is correct for firebird v2.x, it is for fb v3
|
||||
else
|
||||
CREATE_TABLE := 'CREATE TABLE ';
|
||||
|
||||
if ATableName = ContactsTableName then begin
|
||||
FConnection.ExecuteDirect(
|
||||
'CREATE TABLE Contacts ('+
|
||||
CREATE_TABLE + 'Contacts ('+
|
||||
'RecordID ' + FIDFieldTypeNameInSQL + ', '+
|
||||
'ResourceID INTEGER, '+
|
||||
'FirstName VARCHAR(50), '+
|
||||
@@ -239,7 +252,7 @@ begin
|
||||
end else
|
||||
if ATableName = EventsTableName then begin
|
||||
FConnection.ExecuteDirect(
|
||||
'CREATE TABLE Events ('+
|
||||
CREATE_TABLE + 'Events ('+
|
||||
'RecordID ' + FIdFieldTypeNameInSQL + ', '+
|
||||
'StartTime TIMESTAMP, '+
|
||||
'EndTime TIMESTAMP, '+
|
||||
@@ -282,7 +295,7 @@ begin
|
||||
end else
|
||||
if ATableName = ResourceTableName then begin
|
||||
FConnection.ExecuteDirect(
|
||||
'CREATE TABLE Resources ( '+
|
||||
CREATE_TABLE + 'Resources ( '+
|
||||
'ResourceID ' + FIdFieldTypeNameInSQL + ', '+
|
||||
'Description VARCHAR(255), '+
|
||||
'Notes VARCHAR(1024), '+
|
||||
@@ -302,7 +315,7 @@ begin
|
||||
end else
|
||||
if ATableName = TasksTableName then begin
|
||||
FConnection.ExecuteDirect(
|
||||
'CREATE TABLE Tasks ('+
|
||||
CREATE_TABLE + 'Tasks ('+
|
||||
'RecordID ' + FIdFieldTypeNameInSQL + ', '+
|
||||
'ResourceID INTEGER, '+
|
||||
'Complete ' + FBoolFieldTypeNameInSQL + ', '+
|
||||
@@ -450,7 +463,12 @@ end;
|
||||
autoincrement fields. }
|
||||
function TVpZeosDatastore.GetNextID(TableName: string): integer;
|
||||
begin
|
||||
result := -1;
|
||||
{
|
||||
if (FConnection.Protocol = 'firebird') then // Optionally use this for firebird 2.x
|
||||
Result := random(maxInt)
|
||||
else
|
||||
}
|
||||
Result := -1;
|
||||
end;
|
||||
|
||||
function TVpZeosDatastore.GetResourceTable : TDataset;
|
||||
|
Reference in New Issue
Block a user