[fpc-pascal] Re: How to insert a record and get the primary keywith sqldb?
Felipe Monteiro de Carvalho
felipemonteiro.carvalho at gmail.com
Sat Oct 22 21:57:43 CEST 2011
On Sat, Oct 22, 2011 at 9:38 PM, Ludo Brands <ludo.brands at free.fr> wrote:
> Nextval takes a regclass as parameter, not an identifier (column). So, use
> single quotes: SELECT nextval('GameSession_SessionId_seq') as res;
But Postgres requires double quotes or else it will lowercase the
entire identifier and it won't match. It seams that it moves forward
if I use both types of quotes! Like this:
OPDebugLn('[TGameSessionComm.CreateSessionResponse] Obtaining New
Primary Key');
SQLGameSession.SQL.Text:='SELECT
nextval(''"GameSession_SessionId_seq"'') as res;';
SQLGameSession.Open;
FSessionId := (SQLGameSession.Fields[0] as TLargeIntField).AsLargeInt;
SQLGameSession.Close;
But now I get a new error "Cannot open a non-select statement" o.O
Regardless of the final "as res;" being there or not.
--
Felipe Monteiro de Carvalho
More information about the fpc-pascal
mailing list