[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 Michael

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 handl

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: 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 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 ma

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

2011-10-22 Thread Ludo Brands
> Error: Preparation 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 regc

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." > >

Re: [fpc-pascal] Re: 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 5:42 PM, Michael Van Canneyt wrote: > Just a use a TSQLQuery: Are you sure that it is really like that? My code is virtually the same as yours and I already checked everything I could come up with. Using the final "as res;" or not, checked that the sequence exists in the d

[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 mus

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 evi

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 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, etc. // ARecordValues

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: [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 wrote: > On Saturday 22 October 2011 17.23:38 Marcos Douglas wrote: >> On Sat, Oct 22, 2011 at 11:21 AM,   wrote: >> >>  DBComm.SQLTransaction.StartTransaction; <-- Fails here with >> >> "transaction already active" >> > >> > Correct. The default t

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, wrote: > >> DBComm.SQLTransaction.StartTransaction; <-- Fails here with > >> "transaction already active" > > > > Correct. The default transaction is made active after connecting. > > You should call

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 wh

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, dja

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 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 > f

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 the

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 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 expecting; The "scop

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, 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 commit or > rollb

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 > 'abstract

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 ins

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 so

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

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 t

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, 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 cas

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, 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 the sequence value after

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 pr

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

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] 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 TSQLQuer

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 s

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 o

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;

[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

[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 := lGam

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 wha

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 shoulder

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

2011-10-22 Thread Juha Manninen
2011/10/22 Gregory M. Turner > > 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 > separat

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 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 > does Destroy d

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 includi

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

2011-10-22 Thread Michael Müller
Am 22.10.2011 um 09:08 schrieb Frank Church: > > > On 22 October 2011 07:20, Felipe Monteiro de Carvalho > 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 rememb

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 := TMyObj

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 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 is: > > >

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 "procedu

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 > MyObject.DoSom

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. >