asbegin if (new.id is null) then new.id = gen_id(gen_r_id,1);end
/******************************************************************************//*** Generated by IBExpert 26.03.2010 21:36:59 ***//******************************************************************************/SET SQL DIALECT 3;SET NAMES NONE;/******************************************************************************//*** Tables ***//******************************************************************************/CREATE GENERATOR GEN_REPORTS_ID;CREATE TABLE REPORTS ( REPORTID INTEGER NOT NULL, REPORTNAME INTEGER, REPORTSOURCE VARCHAR(255), REPORTBODY BLOB SUB_TYPE 1 SEGMENT SIZE 16384, REPORTPARAMS VARCHAR(255));/******************************************************************************//*** Triggers ***//******************************************************************************/SET TERM ^ ;/******************************************************************************//*** Triggers for tables ***//******************************************************************************//* Trigger: REPORTS_BI */CREATE OR ALTER TRIGGER REPORTS_BI FOR REPORTSACTIVE BEFORE INSERT POSITION 0ASBEGIN IF (NEW.REPORTID IS NULL) THEN NEW.REPORTID = GEN_ID(GEN_REPORTS_ID,1);END^SET TERM ; ^/******************************************************************************//*** Privileges ***//******************************************************************************/
#include "core/ibpp.h"#include <iostream>#include <string>int main(int argc, char *argv[]){ IBPP::Database db1; db1 = IBPP::DatabaseFactory("localhost", "D:\\bookstore.fdb", "sysdba", "masterkey"); db1->Connect(); IBPP::Transaction tr1 = IBPP::TransactionFactory(db1, IBPP::amWrite, IBPP::ilConcurrency, IBPP::lrWait); tr1->Start(); IBPP::Statement st1 = IBPP::StatementFactory(db1, tr1); st1->Execute("INSERT INTO REPORTS(REPORTID,REPORTNAME) VALUES(NULL,11) RETURNING REPORTID"); tr1->Commit(); int test_id = -1024; st1->Get(1, test_id); std::cout << "returned id is " << test_id << std::endl; db1->Disconnect(); return 0;}