Re: [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-22 Thread Felipe Monteiro de Carvalho
I understand Assigned as being the same as nil, so Assigned(Object) = Object nil I vaguely remember that it could be safer in some corner case, but I don't remember ever meting that. Free is how you release the memory allocated for a object. Free calls Destroy. Never call Destroy manually.

Re: [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-22 Thread Alexander Shishkin
22.10.2011 10:20, Felipe Monteiro de Carvalho пишет: I understand Assigned as being the same as nil, so Assigned(Object) = Object nil I vaguely remember that it could be safer in some corner case, but I don't remember ever meting that. Method pointers?

Re: [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-22 Thread Frank Church
On 22 October 2011 07:20, Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com wrote: I understand Assigned as being the same as nil, so Assigned(Object) = Object nil I vaguely remember that it could be safer in some corner case, but I don't remember ever meting that. Free is

RE : [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-22 Thread Ludo Brands
Nil is not a routine, it is a value, it means that the object is empty, it does not exist / is not allocated. Nil in existing implementations that I know is represented by the value zero. The typical life-cycle of a object is: MyObject := TMyObject.Create; try

RE : [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-22 Thread Ludo Brands
When the loop runs again Assigned in InitVars is false so as soon as those FBreakStrings and SCStrings are accessed within the loop a SIGSEGV occurs. So what I want to know is whether Assigned remains true when Free is executed. See my previous answer. There is a helper function

Re: RE : [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-22 Thread Frank Church
On 22 October 2011 08:14, Ludo Brands ludo.bra...@free.fr wrote: Nil is not a routine, it is a value, it means that the object is empty, it does not exist / is not allocated. Nil in existing implementations that I know is represented by the value zero. The typical life-cycle of a object

Re: [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-22 Thread tcoq
Hello, Instead of .Free in your FreeVars routine, you should use FreeAndNil( theobject). The correct lifecycle for class objects is : var anObject : TMyObject; begin anObject := nil; //not needed for class attributes. Required for local function or global unit variables. anObject :=

RE : RE : [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-22 Thread Ludo Brands
Does that mean that Free itself reclaims the memory used by the object's fields and properties but does not release the memory used by the TObject or pointer itself, where as setting it to nil or executing Destroy does, or does Destroy do something different? All memory is released

Re: RE : [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-22 Thread Felipe Monteiro de Carvalho
On Sat, Oct 22, 2011 at 9:36 AM, Frank Church vfcli...@gmail.com wrote: Does that mean that Free itself reclaims the memory used by the object's fields and properties but does not release the memory used by the TObject or pointer itself, where as setting it to nil or executing Destroy does, or

Re: [fpc-pascal] Delphi's anonymous functions in Free Pascal

2011-10-22 Thread Juha Manninen
2011/10/22 Gregory M. Turner g...@malth.us Taking these terms in the broadest sense possible, wouldn't we say that OOP is mostly a functional development paradigm? Not a rhetorical question, I seriously am not sure. OP's somewhat idiosyncratic requirement to put all the OOP metadata in a

Re: [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-22 Thread Mark Morgan Lloyd
Felipe Monteiro de Carvalho wrote: Free is how you release the memory allocated for a object. Free calls Destroy. Never call Destroy manually. When you implement the destructor you always implement Destroy, never change Free. A number of years ago, Matthew Jones's wife looked over his

Re: [fpc-pascal] How are Assigned, Free, Nil and Destroy related?

2011-10-22 Thread Marco van de Voort
In our previous episode, Felipe Monteiro de Carvalho said: Nil is not a routine, it is a value, it means that the object is empty, it does not exist / is not allocated. Nil in existing implementations that I know is represented by the value zero. Look better in, euh, Free Pascal, and see what

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

2011-10-22 Thread Felipe Monteiro de Carvalho
Hello, Yet another chapter of my database problems =) Ok, now I want to insert a record in my table and I would like to obtain the auto-generated PrimaryKey I tryed a number of options: SQLGameSession.Insert(); SQLGameSession.Edit; SQLGameSession.FieldByName('GameEvent').AsInteger :=

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

2011-10-22 Thread Felipe Monteiro de Carvalho
Hello, Ok, searching some more I see that select scope_identity() could return the generated primary key. But how to get the value?  DBComm.PQConnection.ExecuteDirect(SQLText); The method above has no return value =( -- Felipe Monteiro de Carvalho

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

2011-10-22 Thread michael . vancanneyt
On Sat, 22 Oct 2011, Felipe Monteiro de Carvalho wrote: Hello, Yet another chapter of my database problems =) Ok, now I want to insert a record in my table and I would like to obtain the auto-generated PrimaryKey I tryed a number of options: SQLGameSession.Insert(); SQLGameSession.Edit;

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

2011-10-22 Thread Marco van de Voort
In our previous episode, Felipe Monteiro de Carvalho said: Ok, now I want to insert a record in my table and I would like to obtain the auto-generated PrimaryKey This is a classic problem, since SQL simply doesn't support this. So all DBs do something else, for postgresql there are sequence

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

2011-10-22 Thread michael . vancanneyt
On Sat, 22 Oct 2011, Marco van de Voort wrote: In our previous episode, Felipe Monteiro de Carvalho said: Ok, now I want to insert a record in my table and I would like to obtain the auto-generated PrimaryKey This is a classic problem, since SQL simply doesn't support this. So all DBs do

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

2011-10-22 Thread michael . vancanneyt
On Sat, 22 Oct 2011, Felipe Monteiro de Carvalho wrote: Hello, Ok, searching some more I see that select scope_identity() could return the generated primary key. But how to get the value?  DBComm.PQConnection.ExecuteDirect(SQLText); The method above has no return value =( Use a TSQLQuery

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

2011-10-22 Thread Inoussa OUEDRAOGO
Ok, searching some more I see that select scope_identity() could return the generated primary key. But how to get the value? Better use the RETURNING* clause** as it clearly state the column value you are expecting; The scope_identity() may be a source of subtle bugs that are difficult to

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

2011-10-22 Thread Martin Schreiber
On Saturday 22 October 2011 15.21:40 Marco van de Voort wrote: In our previous episode, Felipe Monteiro de Carvalho said: Ok, now I want to insert a record in my table and I would like to obtain the auto-generated PrimaryKey This is a classic problem, since SQL simply doesn't support this.

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

2011-10-22 Thread Michael Van Canneyt
On Sat, 22 Oct 2011, Martin Schreiber wrote: On Saturday 22 October 2011 15.21:40 Marco van de Voort wrote: In our previous episode, Felipe Monteiro de Carvalho said: Ok, now I want to insert a record in my table and I would like to obtain the auto-generated PrimaryKey This is a classic

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

2011-10-22 Thread Felipe Monteiro de Carvalho
On Sat, Oct 22, 2011 at 3:33 PM, michael.vancann...@wisa.be wrote: 2. or sequences, which must be generated manually before the insert (DB2, Oracle, Firebird) using a special   API, but which may or may not be generated in an AFTER INSERT trigger.   In which case it's impossible to retrieve

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

2011-10-22 Thread Michael Van Canneyt
On Sat, 22 Oct 2011, Felipe Monteiro de Carvalho wrote: On Sat, Oct 22, 2011 at 3:33 PM, michael.vancann...@wisa.be wrote: 2. or sequences, which must be generated manually before the insert (DB2, Oracle, Firebird) using a special   API, but which may or may not be generated in an AFTER

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

2011-10-22 Thread Marco van de Voort
In our previous episode, michael.vancann...@wisa.be said: Ok, now I want to insert a record in my table and I would like to obtain the auto-generated PrimaryKey This is a classic problem, since SQL simply doesn't support this. So all DBs do something else, for postgresql there are

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

2011-10-22 Thread Martin Schreiber
On Saturday 22 October 2011 16.20:13 Michael Van Canneyt wrote: Note that I did not invest this stuff ... I just copied from stuff to create other tables which were already in the project. You must get a value first, and pass it along to the insert statement. Auto-generation is not

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

2011-10-22 Thread Michael Van Canneyt
On Sat, 22 Oct 2011, Marco van de Voort wrote: In our previous episode, michael.vancann...@wisa.be said: Ok, now I want to insert a record in my table and I would like to obtain the auto-generated PrimaryKey This is a classic problem, since SQL simply doesn't support this. So all DBs do

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

2011-10-22 Thread Michael Van Canneyt
On Sat, 22 Oct 2011, Martin Schreiber wrote: On Saturday 22 October 2011 16.20:13 Michael Van Canneyt wrote: Note that I did not invest this stuff ... I just copied from stuff to create other tables which were already in the project. You must get a value first, and pass it along to the

RE : [fpc-pascal] How to insert a record and get the primary key withsqldb?

2011-10-22 Thread Ludo Brands
Afaik Zeos manages to abstract this for all these dbs by having a sequence object. I fail to see how it can do that. E.g. the mechanism by Martin is just a trick to update a field value after an insert/update. That's a fine/useful mechanism, but not what I'd call 'abstracting'.

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

2011-10-22 Thread Marcos Douglas
On Sat, Oct 22, 2011 at 11:21 AM, michael.vancann...@wisa.be wrote:  DBComm.SQLTransaction.StartTransaction; -- Fails here with transaction already active Correct. The default transaction is made active after connecting. You should call StartTransaction on this transaction only after a

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

2011-10-22 Thread Marcos Douglas
On Sat, Oct 22, 2011 at 11:35 AM, Inoussa OUEDRAOGO inouss...@gmail.com wrote: Ok, searching some more I see that select scope_identity() could return the generated primary key. But how to get the value? Better use the RETURNING* clause** as it clearly state the column value you are

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

2011-10-22 Thread Felipe Monteiro de Carvalho
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

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

2011-10-22 Thread Marcos Douglas
On Sat, Oct 22, 2011 at 1:33 PM, Felipe Monteiro de Carvalho felipemonteiro.carva...@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

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

2011-10-22 Thread Michael Van Canneyt
On Sat, 22 Oct 2011, 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,

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

2011-10-22 Thread Michael Van Canneyt
On Sat, 22 Oct 2011, Ludo Brands wrote: Afaik Zeos manages to abstract this for all these dbs by having a sequence object. I fail to see how it can do that. E.g. the mechanism by Martin is just a trick to update a field value after an insert/update. That's a fine/useful mechanism, but not

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

2011-10-22 Thread Martin Schreiber
On Saturday 22 October 2011 17.23:38 Marcos Douglas wrote: On Sat, Oct 22, 2011 at 11:21 AM, michael.vancann...@wisa.be wrote: DBComm.SQLTransaction.StartTransaction; -- Fails here with transaction already active Correct. The default transaction is made active after connecting. You

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

2011-10-22 Thread Marcos Douglas
On Sat, Oct 22, 2011 at 1:53 PM, Martin Schreiber mse00...@gmail.com wrote: On Saturday 22 October 2011 17.23:38 Marcos Douglas wrote: On Sat, Oct 22, 2011 at 11:21 AM,  michael.vancann...@wisa.be wrote:  DBComm.SQLTransaction.StartTransaction; -- Fails here with transaction already active

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

2011-10-22 Thread Martin Schreiber
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

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

2011-10-22 Thread Felipe Monteiro de Carvalho
Ok, thanks a lot =) On 10/22/11, Michael Van Canneyt mich...@freepascal.org wrote: ... And mainly the reason I think it is not abstractable... :-) In this case I would suggest to abstract it like this: // ASequenceName - The name of the sequence for usage in Postgres, etc. Ignored for MSSQL,

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

2011-10-22 Thread Graeme Geldenhuys
On 22/10/2011, Felipe Monteiro de Carvalho wrote: Yet another chapter of my database problems =) As this message thread proves, there are many issues with Auto-inc field, so simply DON'T USE THEM! You have many alternatives, which will save you LOTS of grey hairs. Auto-Inc field are just

[fpc-pascal] Indy 10 HTTP Server component with FPC

2011-10-22 Thread Graeme Geldenhuys
Hi, Is anybody here using the Indy 10 components with FPC? More specifically, the HTTP Server component. My project compiles fine, but when I activate the HTTP Server I get the following error. Socket error # 98. Address already in use. I know that under Linux, if you use a port 1024 you must

Re: [fpc-pascal] Indy 10 HTTP Server component with FPC

2011-10-22 Thread Marco van de Voort
In our previous episode, Graeme Geldenhuys said: Is anybody here using the Indy 10 components with FPC? More specifically, the HTTP Server component. My project compiles fine, but when I activate the HTTP Server I get the following error. Socket error # 98. Address already in use. I know

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

Re: [fpc-pascal] Indy 10 HTTP Server component with FPC

2011-10-22 Thread Graeme Geldenhuys
On 22/10/2011, Marco van de Voort wrote: I haven't tried for years, but I can remember some strange problems designtime that went away if you manually added a tidbinding in formcreate. I'm not using design-time usage at all, everything is done manually via code. I'm creating a TIdHTTPServer

Re: [fpc-pascal] Indy 10 HTTP Server component with FPC

2011-10-22 Thread Marco van de Voort
In our previous episode, Graeme Geldenhuys said: designtime that went away if you manually added a tidbinding in formcreate. I'm not using design-time usage at all, everything is done manually via code. I'm creating a TIdHTTPServer instance via code, set the port, one basic event handler,

[fpc-pascal] FPC has multiple HTTP server components

2011-10-22 Thread Graeme Geldenhuys
Hi, I was looking through the FCL code and noticed that there seems to be more than one HTTP server component. What is the difference between them, and which one would be the better option as the basis for a HTTP based n-tier application server (for use with tiOPF). I found the recent one