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

Martin Schreiber mse00000 at gmail.com
Sat Oct 22 18:06:54 CEST 2011


On Saturday 22 October 2011 17.33:11 Felipe Monteiro de Carvalho 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.
> 
> thanks,

Postgres documenatation is here:

http://www.postgresql.org/docs/manuals/
http://www.postgresql.org/docs/8.3/static/functions-sequence.html

MSEgui calls getsqlresult() with the statement
"
function tmsepqconnection.readsequence(const sequencename: string): string;
begin
 result:= 'select nextval(''' +sequencename+''') as res;';
end;
"
returns. Instead of the MSEgui getsqlresult() function use a tsqlquery in 
sqldb.

Martin



More information about the fpc-pascal mailing list