I have tried several ways, including on SO.
The following MYSQL code does not work in Firebird:
CREATE TABLE publications (
INT NOT NULL AUTO_INCREMENT ,
PRIMARY KEY (`id`),
filename varchar(500) not null unique,
title varchar(500) DEFAULT NULL,
authors varchar(1000) DEFAULT NULL,
uploader int DEFAULT NULL,
keywords varchar(500) DEFAULT NULL,
rawtext text,
lastmodified timestamp default CURRENT_TIMESTAMP
);
So to achieve this in Firebird, I am using:
CREATE TABLE publications (
id int NOT NULL PRIMARY KEY,
filename varchar(500) NOT NULL UNIQUE,
title varchar(500) DEFAULT NULL,
authors varchar(1000) DEFAULT NULL,
uploader int DEFAULT NULL,
keywords varchar(500) DEFAULT NULL,
rawtext text,
file_data BLOB SUB_TYPE 0,
insertdate timestamp DEFAULT NULL
);
CREATE GENERATOR gen_t1_id;
SET GENERATOR gen_t1_id TO 0;
set term !! ;
CREATE TRIGGER journalInsertionTrigger FOR publications
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
if (NEW.ID is NULL) then NEW.ID = GEN_ID(GEN_T1_ID, 1);
END!!
set term ; !!
And with the above, I get the error:
Batch execution aborted The returned message was: Dynamic SQL Error SQL error code = -104 Token unknown - line 13, char 2 CREATE"
When I uncomment //FbTransaction fbt = Connection.BeginTransaction();
and //fbt.Commit();
Execute requires the Command object to have a Transaction object when the Connection object assigned to the command is in a pending local transaction. The Transaction property of the Command has not been initialized.
I am using the following C# code:
//FbTransaction fbt = Connection.BeginTransaction(); //
FbBatchExecution fbe = new FbBatchExecution( Connection );
fbe.SqlStatements = new System.Collections.Specialized.StringCollection();//.Add( queryString ); // Your string here
fbe.SqlStatements.Add( queryString ); // Your string here
fbe.Execute();
//fbt.Commit();
NB: Setting set term ; !!
at the beginning of the sql code gives the error: The type of the SQL statement could not be determinated
How do I do this?