Subject Re: [ib-support] SET GENERATOR in a stored procedure
Author Martijn Tonies
Hi Tim,


> I suppose I'd better explain the situation :-)
>
> I write software in Delphi that does EFT transfers to banks from retail
> outlets. I am busy converting the software from DBase III + files to
> Interbase / Firebird.
>
> Transactions are sent through to the bank in batches. At the end of each
> batch, a batch cut off message is sent. It is a bank requirement that each
> transaction in the batch is individually numbered within that batch, and
> that the transaction sequence numbers in a batch start at 1 in each new
batch.
>
> So I have a INITBATCH procedure which creates a new batch record and
> returns a set of default values. What I wanted to do was to use the
> generator to generate the values automatically.
>
> Also, how do I select the value in a generator? Can I use the following
SQL
> in a stored procedure - and if not, how would I get the present value
> without incrementing the generator value?
>
> SELECT * FROM GEN_ID (GEN_MYGENERATOR, 0);

How about simply:

myvar = GEN_ID(mygen, 0);


You cannot SET a generator because that's a DDL statement. These
are not allowed inside procedures.

Is it absolutely required to reset the generator?


With regards,

Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
http://www.upscene.com

See you at the First European Firebird Conference in May in Fulda, Germany
http://www.firebird-conference.com