Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SET term ^;
- CREATE TABLE %tablename%
- (
- %tableprefix%_id_%tablename% INTEGER NOT NULL
- , %tableprefix%_bla INTEGER
- , %tableprefix%_id_client INTEGER
- , %tableprefix%_history BLOB sub_type text
- , %tableprefix%_report BLOB sub_type 0
- , %tableprefix%_report_compression_type d_compression_type
- , %tableprefix%_report_compressed_size INTEGER
- , %tableprefix%_report_uncompressed_size INTEGER
- , CONSTRAINT uq_%tableprefix%_bla UNIQUE(%tableprefix%_bla)
- , CONSTRAINT fk_%tableprefix%_id_client FOREIGN KEY (%tableprefix%_id_client) REFERENCES client (cl_id_client)
- , CONSTRAINT pk_%tableprefix%_id_%tablename% PRIMARY KEY (%tableprefix%_id_%tablename%)
- ) ^
- CREATE generator gen_%tableprefix%_id_%tablename% ^
- SET generator gen_%tableprefix%_id_%tablename% TO 0 ^
- CREATE TRIGGER %tablename%_gen
- FOR %tablename%
- active BEFORE INSERT
- AS
- BEGIN
- IF (NEW.%tableprefix%_id_%tablename% IS NULL) THEN BEGIN
- NEW.%tableprefix%_id_%tablename% = gen_id( gen_%tableprefix%_id_%tablename%, 1 );
- END
- END
- ^
- SET term ;^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement