[fpc-pascal] Re: How to insert a record and get the primary key with sqldb?

Marcos Douglas md at delfire.net
Sat Oct 22 17:41:40 CEST 2011


On Sat, Oct 22, 2011 at 1:33 PM, Felipe Monteiro de Carvalho
<felipemonteiro.carvalho at gmail.com> wrote:
> ugh, any ideas how I can obtain the next sequence value using sqldb
> and postgres then?
>
> I have never used sequence values before, and while I am googling I
> only found either answers which are specific for a particular
> framework (java, djambo, whatever) or people claiming that it should
> generate the index automatically! o.O Which clearly it is not doing...
> I couldn't yet get a generic answer using SQL supported by Postgres,
> or whatever thing which I could reuse in sqldb.

You can use:
- Stored Procedures (SP): one for each table;
- "Dynamic SP": pass the generic SQL to the SP and return the scope_identity();
- GUID: Use a column to save a GUID. The real ID can be autoincrement
but you do not need it. You can found the register using the GUID.

Marcos Douglas



More information about the fpc-pascal mailing list