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

2011-10-24 Thread Ludo Brands
What's funny is that I never understood how the MySQL/SQL-Server way could correctly work. For example I have 2 tables, both with an auto-incremental field. Table 1 has an after insert trigger that does an extra insert in table 2. When I do an insert in table 1 , what does

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

2011-10-24 Thread michael . vancanneyt
On Mon, 24 Oct 2011, Ludo Brands wrote: What's funny is that I never understood how the MySQL/SQL-Server way could correctly work. For example I have 2 tables, both with an auto-incremental field. Table 1 has an after insert trigger that does an extra insert in table 2. When I do an insert

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

2011-10-24 Thread Mark Morgan Lloyd
michael.vancann...@wisa.be wrote: Before MySQL 5.0.12 last_insert_id returns table 2, since 5.0.12 table 1. Triggers were introduced in 5.0.2. SQLServer's SCOPE_IDENTITY() returns table 1 (the trigger is out of scope) and @@IDENTITY returns 2. This mess is why I prefer sequences :-) :-)

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

2011-10-24 Thread Graeme Geldenhuys
On 2011-10-24 15:15, Ludo Brands wrote: Most databases have functions to create GUID's (with different randomness quality and different storage requirements): No, no, no... you are missing the point of this thread, and what I meant by using a GUID. The idea is that you can created the GUID

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

2011-10-24 Thread Marcos Douglas
On Mon, Oct 24, 2011 at 11:26 AM, Graeme Geldenhuys graemeg.li...@gmail.com wrote: On 2011-10-24 15:15, Ludo Brands wrote: Most databases have functions to create GUID's (with different randomness quality and different storage requirements): No, no, no... you are missing the point of

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

2011-10-23 Thread Ludo Brands
This code: SQLGameSession := TSQLQuery.Create(nil); SQLGameSession.Transaction := DBComm.SQLTransaction; SQLGameSession.Database := DBComm.PQConnection; SQLGameSession.FieldDefs.Add('SessionId', ftLargeint); SQLGameSession.FieldDefs.Add('GameEvent', ftLargeint);

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

2011-10-22 Thread Ludo Brands
Error: bPreparation of query failed. (PostgreSQL: ERROR: column GameSession_SessionId_seq does not exist LINE 1: prepare prepst2 as SELECT nextval(GameSession_SessionId_se... SQLGameSession.SQL.Text:='SELECT nextval(GameSession_SessionId_seq) as res;'; Nextval takes a regclass as

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

2011-10-22 Thread Felipe Monteiro de Carvalho
On Sat, Oct 22, 2011 at 9:38 PM, Ludo Brands ludo.bra...@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