SET SQL DIALECT 3; 

CREATE DATABASE 'localhost/3050:c:\dbexpressfirebird\bd_tuto.fdb' DEFAULT CHARACTER SET ISO8859_1 ;


/*  Generators or sequences */
CREATE GENERATOR GEN_T_CONTACT_CON_ID;


/* Table: T_CONTACT_CON, Owner: SYSDBA */
CREATE TABLE T_CONTACT_CON (CON_ID INTEGER NOT NULL,
        CON_EMAIL VARCHAR(64),
        CON_SITE_WEB VARCHAR(128),
        CON_NOM VARCHAR(30),
        CON_PRENOM VARCHAR(30),
        CON_TELEPHONE VARCHAR(30),
        CON_FAX VARCHAR(30),
        CON_ADRESSE VARCHAR(255),
        CON_COMMENTAIRES VARCHAR(255),
        CON_DATE_NAISSANCE DATE,
CONSTRAINT PK_T_CONTACT_CON PRIMARY KEY (CON_ID));
COMMIT WORK;
SET AUTODDL OFF;
SET TERM ^ ;

/* Stored procedures */
CREATE PROCEDURE SP_GEN_T_CONTACT_CON_ID RETURNS (ID INTEGER)
AS 
BEGIN EXIT; END ^

ALTER PROCEDURE SP_GEN_T_CONTACT_CON_ID RETURNS (ID INTEGER)
AS 
begin  id = gen_id(gen_t_contact_con_id, 1);  suspend;end ^
SET TERM ; ^
COMMIT WORK ;
SET AUTODDL ON;
SET TERM ^ ;

/* Triggers only will work for SQL triggers */
CREATE TRIGGER T_CONTACT_CON_BI FOR T_CONTACT_CON 
ACTIVE BEFORE INSERT POSITION 0 
asbegin  if (new.con_id is null) then    new.con_id = gen_id(gen_t_contact_con_id,1);end ^

COMMIT WORK ^
SET TERM ; ^
