Subject | Why can't I use '--' comments in the following script ? |
---|---|
Author | Erik De Laet |
Post date | 2005-01-15T10:03:56Z |
Hi,
I am writing a program that produces scripts to create Firebird database.
Can someone please tell me why I can't use the '--' comments in script 2
(when I try to create a trigger for automatic CURRENT_DATE and CURRENT_USER
values) ?
A similar syntax when creating a trigger to create a generator field does
work !
I marked the lines with <--------.
I am using the /* */ comments at the moment, but I just want to know why
the '--' comments do not work.
The output presented here is the redirected output from ISQL.
Thanks, Erik
##################################################
SCRIPT 1
##################################################
Use CONNECT or CREATE DATABASE to specify a database
/****************************************************
* Database : C:\FirebirdDB\erik050112-210534.fdb
*
* Gecreëerd op 12-jan-05 , 21:05:34
**************************************************/
SET SQL DIALECT 3;
CREATE DATABASE 'C:\FirebirdDB\erik050112-210534.fdb'
USER 'SYSDBA' PASSWORD 'masterkey'
PAGE_SIZE 8192
DEFAULT CHARACTER SET ISO8859_1;
COMMIT;
QUIT;
Use CONNECT or CREATE DATABASE to specify a database
CONNECT 'C:\FirebirdDB\DbStepper/erik050112-210534.fdb'
USER 'SYSDBA' PASSWORD 'masterkey';
/******************************************************
* Creatie van de globale default domains voor dbname}.fdb
***************************************************/
-- boolean data type
CREATE DOMAIN D_BOOLEAN AS SMALLINT
DEFAULT 0 NOT NULL
CHECK (VALUE IN (1,0));
/************************************************
* Tabel : projects
*
* Er zijn 7 velden in deze tabel.
************************************************/
CREATE TABLE projects
(
p_Id BIGINT ,
p_description INTEGER ,
p_created__by VARCHAR(128) ,
p_created__at DATE ,
p_modified__by VARCHAR(128) ,
p_modified__at DATE ,
p_data__version INTEGER
);
COMMIT;
/***********************************************
* Generator : GEN_projects_p_Id
* Trigger : BI_projects_p_Id
***********************************************/
-- GENERATOR
CREATE GENERATOR GEN_projects_p_Id;
-- TRIGGER
SET TERM ^^ ;
CREATE TRIGGER BI_projects_p_Id FOR projects
ACTIVE BEFORE INSERT POSITION 0 AS
begin
if (new.p_Id is null)
then new.p_Id = gen_id(GEN_projects_p_Id, 1);
end
^^
COMMIT ^^
SET TERM ; ^^
/*********************************************
* Creëren van de triggers die de automatische velden invullen.
* Trigger : BIU_projects__AUTO voor tabel projects.
*********************************************/
/* trigger */ <----- THIS DOES WORK
SET TERM ^^;
CREATE TRIGGER BIU_projects__AUTO FOR projects
ACTIVE BEFORE
INSERT
OR
UPDATE
POSITION 99 AS
begin
if (INSERTING)
then begin
new.p_created__by = CURRENT_USER;
new.p_created__at = CURRENT_TIMESTAMP;
new.p_data__version = 1;
end
if (UPDATING)
then begin
new.p_modified__by = CURRENT_USER;
new.p_modified__at = CURRENT_TIMESTAMP;
end
end
^^
COMMIT ^^
SET TERM ;^^
QUIT;
##################################################
SCRIPT 2
##################################################
Use CONNECT or CREATE DATABASE to specify a database
/****************************************************
* Database : C:\FirebirdDB\erik050112-210557.fdb
*
* Gecreëerd op 12-jan-05 , 21:05:57
*************************************************/
SET SQL DIALECT 3;
CREATE DATABASE 'C:\FirebirdDB\erik050112-210557.fdb'
USER 'SYSDBA' PASSWORD 'masterkey'
PAGE_SIZE 8192
DEFAULT CHARACTER SET ISO8859_1;
COMMIT;
QUIT;
Use CONNECT or CREATE DATABASE to specify a database
CONNECT 'C:\FirebirdDB\DbStepper/erik050112-210557.fdb'
USER 'SYSDBA' PASSWORD 'masterkey';
/**************************************************
* Creatie van de globale default domains voor dbname}.fdb
**************************************************/
-- boolean data type
CREATE DOMAIN D_BOOLEAN AS SMALLINT
DEFAULT 0 NOT NULL
CHECK (VALUE IN (1,0));
/***************************************************
* Tabel : projects
*
* Er zijn 7 velden in deze tabel.
***************************************************/
CREATE TABLE projects
(
p_Id BIGINT ,
p_description INTEGER ,
p_created__by VARCHAR(128) ,
p_created__at DATE ,
p_modified__by VARCHAR(128) ,
p_modified__at DATE ,
p_data__version INTEGER
);
COMMIT;
/***************************************************
* Generator : GEN_projects_p_Id
* Trigger : BI_projects_p_Id
***************************************************/
-- GENERATOR
CREATE GENERATOR GEN_projects_p_Id;
-- TRIGGER
SET TERM ^^ ;
CREATE TRIGGER BI_projects_p_Id FOR projects
ACTIVE BEFORE INSERT POSITION 0 AS
begin
if (new.p_Id is null)
then new.p_Id = gen_id(GEN_projects_p_Id, 1);
end
^^
COMMIT ^^
SET TERM ; ^^
/**********************************************
* Creëren van de triggers die de automatische velden invullen.
* Trigger : BIU_projects__AUTO voor tabel projects.
**********************************************/
-- trigger <------- BUT THIS DOESN'T WORK ???
SET TERM ^^;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 6, char 5
-TERM
CREATE TRIGGER BIU_projects__AUTO FOR projects
ACTIVE BEFORE
INSERT
OR
UPDATE
POSITION 99 AS
begin
if (INSERTING)
then begin
new.p_created__by = CURRENT_USER;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Unexpected end of command
new.p_created__at = CURRENT_TIMESTAMP;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, char 1
-new
new.p_data__version = 1;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, char 1
-new
end
if (UPDATING)
then begin
new.p_modified__by = CURRENT_USER;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, char 1
-end
new.p_modified__at = CURRENT_TIMESTAMP;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, char 1
-new
end
end
^^
COMMIT ^^
SET TERM ;^^
QUIT;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, char 1
-end
[Non-text portions of this message have been removed]
I am writing a program that produces scripts to create Firebird database.
Can someone please tell me why I can't use the '--' comments in script 2
(when I try to create a trigger for automatic CURRENT_DATE and CURRENT_USER
values) ?
A similar syntax when creating a trigger to create a generator field does
work !
I marked the lines with <--------.
I am using the /* */ comments at the moment, but I just want to know why
the '--' comments do not work.
The output presented here is the redirected output from ISQL.
Thanks, Erik
##################################################
SCRIPT 1
##################################################
Use CONNECT or CREATE DATABASE to specify a database
/****************************************************
* Database : C:\FirebirdDB\erik050112-210534.fdb
*
* Gecreëerd op 12-jan-05 , 21:05:34
**************************************************/
SET SQL DIALECT 3;
CREATE DATABASE 'C:\FirebirdDB\erik050112-210534.fdb'
USER 'SYSDBA' PASSWORD 'masterkey'
PAGE_SIZE 8192
DEFAULT CHARACTER SET ISO8859_1;
COMMIT;
QUIT;
Use CONNECT or CREATE DATABASE to specify a database
CONNECT 'C:\FirebirdDB\DbStepper/erik050112-210534.fdb'
USER 'SYSDBA' PASSWORD 'masterkey';
/******************************************************
* Creatie van de globale default domains voor dbname}.fdb
***************************************************/
-- boolean data type
CREATE DOMAIN D_BOOLEAN AS SMALLINT
DEFAULT 0 NOT NULL
CHECK (VALUE IN (1,0));
/************************************************
* Tabel : projects
*
* Er zijn 7 velden in deze tabel.
************************************************/
CREATE TABLE projects
(
p_Id BIGINT ,
p_description INTEGER ,
p_created__by VARCHAR(128) ,
p_created__at DATE ,
p_modified__by VARCHAR(128) ,
p_modified__at DATE ,
p_data__version INTEGER
);
COMMIT;
/***********************************************
* Generator : GEN_projects_p_Id
* Trigger : BI_projects_p_Id
***********************************************/
-- GENERATOR
CREATE GENERATOR GEN_projects_p_Id;
-- TRIGGER
SET TERM ^^ ;
CREATE TRIGGER BI_projects_p_Id FOR projects
ACTIVE BEFORE INSERT POSITION 0 AS
begin
if (new.p_Id is null)
then new.p_Id = gen_id(GEN_projects_p_Id, 1);
end
^^
COMMIT ^^
SET TERM ; ^^
/*********************************************
* Creëren van de triggers die de automatische velden invullen.
* Trigger : BIU_projects__AUTO voor tabel projects.
*********************************************/
/* trigger */ <----- THIS DOES WORK
SET TERM ^^;
CREATE TRIGGER BIU_projects__AUTO FOR projects
ACTIVE BEFORE
INSERT
OR
UPDATE
POSITION 99 AS
begin
if (INSERTING)
then begin
new.p_created__by = CURRENT_USER;
new.p_created__at = CURRENT_TIMESTAMP;
new.p_data__version = 1;
end
if (UPDATING)
then begin
new.p_modified__by = CURRENT_USER;
new.p_modified__at = CURRENT_TIMESTAMP;
end
end
^^
COMMIT ^^
SET TERM ;^^
QUIT;
##################################################
SCRIPT 2
##################################################
Use CONNECT or CREATE DATABASE to specify a database
/****************************************************
* Database : C:\FirebirdDB\erik050112-210557.fdb
*
* Gecreëerd op 12-jan-05 , 21:05:57
*************************************************/
SET SQL DIALECT 3;
CREATE DATABASE 'C:\FirebirdDB\erik050112-210557.fdb'
USER 'SYSDBA' PASSWORD 'masterkey'
PAGE_SIZE 8192
DEFAULT CHARACTER SET ISO8859_1;
COMMIT;
QUIT;
Use CONNECT or CREATE DATABASE to specify a database
CONNECT 'C:\FirebirdDB\DbStepper/erik050112-210557.fdb'
USER 'SYSDBA' PASSWORD 'masterkey';
/**************************************************
* Creatie van de globale default domains voor dbname}.fdb
**************************************************/
-- boolean data type
CREATE DOMAIN D_BOOLEAN AS SMALLINT
DEFAULT 0 NOT NULL
CHECK (VALUE IN (1,0));
/***************************************************
* Tabel : projects
*
* Er zijn 7 velden in deze tabel.
***************************************************/
CREATE TABLE projects
(
p_Id BIGINT ,
p_description INTEGER ,
p_created__by VARCHAR(128) ,
p_created__at DATE ,
p_modified__by VARCHAR(128) ,
p_modified__at DATE ,
p_data__version INTEGER
);
COMMIT;
/***************************************************
* Generator : GEN_projects_p_Id
* Trigger : BI_projects_p_Id
***************************************************/
-- GENERATOR
CREATE GENERATOR GEN_projects_p_Id;
-- TRIGGER
SET TERM ^^ ;
CREATE TRIGGER BI_projects_p_Id FOR projects
ACTIVE BEFORE INSERT POSITION 0 AS
begin
if (new.p_Id is null)
then new.p_Id = gen_id(GEN_projects_p_Id, 1);
end
^^
COMMIT ^^
SET TERM ; ^^
/**********************************************
* Creëren van de triggers die de automatische velden invullen.
* Trigger : BIU_projects__AUTO voor tabel projects.
**********************************************/
-- trigger <------- BUT THIS DOESN'T WORK ???
SET TERM ^^;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 6, char 5
-TERM
CREATE TRIGGER BIU_projects__AUTO FOR projects
ACTIVE BEFORE
INSERT
OR
UPDATE
POSITION 99 AS
begin
if (INSERTING)
then begin
new.p_created__by = CURRENT_USER;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Unexpected end of command
new.p_created__at = CURRENT_TIMESTAMP;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, char 1
-new
new.p_data__version = 1;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, char 1
-new
end
if (UPDATING)
then begin
new.p_modified__by = CURRENT_USER;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, char 1
-end
new.p_modified__at = CURRENT_TIMESTAMP;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, char 1
-new
end
end
^^
COMMIT ^^
SET TERM ;^^
QUIT;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, char 1
-end
[Non-text portions of this message have been removed]