#!/bin/bash
table="$1"
cat <<End
create table ${table} (
    ${table}Id bigint not null,

    constraint ${table}_pk primary key (${table}Id)
);
create generator ${table}Id_gen;
set term ^;
create trigger ${table}_ID for ${table} active before insert position 0 as
begin
    if (new.${table}Id is null) then
        new.${table}Id = gen_id(${table}Id_gen, 1);
end^
set term ;^
set term ^;
create or alter procedure ${table}Id_gen_proc returns (id bigint) as
begin
    select gen_id(${table}Id_gen, 1) from RDB\$DATABASE into :id;
    suspend;
end^
set term ;^
End
