[fpc-pascal] Looking for a Firebird book?

Matt Emson memsom at interalpha.co.uk
Fri Apr 11 14:47:22 CEST 2008


Inoussa OUEDRAOGO wrote:
> Have you try SCOPE_IDENTITY() ? Available at least since SQL SERVER 2000.
> I have used it with success.
>   

Well, yeah. But it's not perfect. I want generators, as in:

create generator an_atomic_counter;
set an_atomic_counter = 1 /*or something like that*/

....
declare variable next_atomic_value int
begin
  next_atomic_value = gen_id(an_atomic_counter, 1);
end

next_atomic_is is alway a unique incremental id, and is *not* tied to a 
specific table. It's not so much the ability to generate a unique id, 
it's the "use auto inc IDENTITY fields or be damned" attitude that Sql 
Server has. The only other option is a GUID. Microsoft's insane "SET 
IDENTITY_INSERT ON|OFF" is also dangerous. Have you ever tried to 
migrate data between to databases using Sql Server? Nightmare!

> from MSDN :
> <quote>
>   Returns the last identity value inserted into an identity column in
>   the same scope. A scope is a module: a stored procedure, trigger,
>   function, or batch. Therefore, two statements are in the same scope
>   if they are in the same stored procedure, function, or batch.
> </quote>
>
> Interesting article ( 10 Things You Shouldn't Do with SQL Server ) :
>   http://www.sqljunkies.ddj.com/Article/92CC4817-604D-4344-8BE0-4490F8ED24B6.scuk
>
>   




More information about the fpc-pascal mailing list