Firebird News

Thursday, March 06, 2008

Here is the final blog tutorial database for cakephp

/****************** GENERATORS ********************/

CREATE GENERATOR GEN_POSTS_ID;
/******************** TABLES **********************/

CREATE TABLE POSTS
(
ID Integer NOT NULL,
TITLE Varchar(50),
BODY Varchar(2000),
CREATED Timestamp,
MODIFIED Timestamp,
PRIMARY KEY (ID)
);


/******************** TRIGGERS ********************/

SET TERM ^ ;
CREATE TRIGGER POSTS_BI FOR POSTS ACTIVE
BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.ID IS NULL) THEN
NEW.ID = GEN_ID(GEN_POSTS_ID, 1);
END^
SET TERM ; ^

GRANT DELETE, INSERT, REFERENCES, SELECT, UPDATE
ON POSTS TO SYSDBA WITH GRANT OPTION;

No comments: