Re: [Lazarus] TSQLQuery

2015-07-30 Thread Corpsman
you mean something like this : If Length(st) 0 Then Begin SQLQuery1.SQL.Text := st; End Else Begin exit; End; Try SQLQuery1.Open; Except On e: Exception Do Begin ShowMessage('Fehler ungültige Eingabe.'#13'Fehlermeldung:'#13 + e.Message); exit; End;

[Lazarus] TSQLQuery

2015-07-30 Thread Terry A. Haimann
After executing a query, is there a way to test if there were any errors? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-17 Thread Marco van de Voort
On Fri, Nov 14, 2014 at 09:41:27PM -0300, silvioprog wrote: Return the value most recently returned by nextval in the current session. This function is identical to currval, except that instead of taking the sequence name as an argument it fetches the value of the last sequence used

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-15 Thread Graeme Geldenhuys
On 2014-11-13 14:07, Reimar Grabowski wrote: It seems to work but it's IMHO not very nice. Ideally I'd like to have TSQLQuery do it for me and offer me some property like SQLQuery.LastInsertID or something along those lines. Is there any way to get the new PK value without manually querying

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Reimar Grabowski
On Thu, 13 Nov 2014 11:33:58 -0300 silvioprog silviop...@gmail.com wrote: I use an own TPreparedStatement (equivalent to TSQLQuery prepared + Params, but my structure does not uses TDataset) that I get the last inserted ID with (pseudo codes): snip Sorry, you lost me there, but not a problem

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Reimar Grabowski
On Thu, 13 Nov 2014 13:26:32 -0300 Marcos Douglas m...@delfire.net wrote: Hi, Take a look in Greyhound project: https://github.com/mdbs99/Greyhound I did and could not see how it helps. Here you can see an example using last id:

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Marcos Douglas
On Fri, Nov 14, 2014 at 10:05 AM, Reimar Grabowski reimg...@web.de wrote: On Thu, 13 Nov 2014 13:26:32 -0300 Marcos Douglas m...@delfire.net wrote: Hi, Take a look in Greyhound project: https://github.com/mdbs99/Greyhound I did and could not see how it helps. It has a code that working with

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Michael Van Canneyt
On Fri, 14 Nov 2014, Reimar Grabowski wrote: On Thu, 13 Nov 2014 13:26:32 -0300 Marcos Douglas m...@delfire.net wrote: Hi, Take a look in Greyhound project: https://github.com/mdbs99/Greyhound I did and could not see how it helps. Here you can see an example using last id:

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Marcos Douglas
On Fri, Nov 14, 2014 at 10:15 AM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, Reimar Grabowski wrote: On Thu, 13 Nov 2014 13:26:32 -0300 Marcos Douglas m...@delfire.net wrote: Hi, Take a look in Greyhound project: https://github.com/mdbs99/Greyhound I did and

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 9:53 AM, Reimar Grabowski reimg...@web.de wrote: On Thu, 13 Nov 2014 11:33:58 -0300 silvioprog silviop...@gmail.com wrote: I use an own TPreparedStatement (equivalent to TSQLQuery prepared + Params, but my structure does not uses TDataset) that I get the last

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 10:15 AM, Michael Van Canneyt mich...@freepascal.org wrote: [...] Connections for databases that have lastinsertID you can call the method created for this: Function GetInsertID: int64; There is a plan to let SQLDB retrieve the value of some fields fro the DB, but

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Michael Van Canneyt
On Fri, 14 Nov 2014, Marcos Douglas wrote: On Fri, Nov 14, 2014 at 10:15 AM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, Reimar Grabowski wrote: On Thu, 13 Nov 2014 13:26:32 -0300 Marcos Douglas m...@delfire.net wrote: Hi, Take a look in Greyhound project:

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Michael Van Canneyt
On Fri, 14 Nov 2014, silvioprog wrote: On Fri, Nov 14, 2014 at 10:15 AM, Michael Van Canneyt mich...@freepascal.org wrote: [...] Connections for databases that have lastinsertID you can call the method created for this: Function GetInsertID: int64; There is a plan to let

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Reimar Grabowski
On Fri, 14 Nov 2014 14:15:08 +0100 (CET) Michael Van Canneyt mich...@freepascal.org wrote: Connections for databases that have lastinsertID you can call the method created for this: Function GetInsertID: int64; That is actually exactly what I was looking for. I was just too dense to realize

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Marcos Douglas
On Fri, Nov 14, 2014 at 10:39 AM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, Marcos Douglas wrote: On Fri, Nov 14, 2014 at 10:15 AM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, Reimar Grabowski wrote: On Thu, 13 Nov 2014 13:26:32

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Marcos Douglas
On Fri, Nov 14, 2014 at 10:40 AM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, silvioprog wrote: On Fri, Nov 14, 2014 at 10:15 AM, Michael Van Canneyt mich...@freepascal.org wrote: [...] Connections for databases that have lastinsertID you can call the

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Michael Van Canneyt
On Fri, 14 Nov 2014, Marcos Douglas wrote: On Fri, Nov 14, 2014 at 10:39 AM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, Marcos Douglas wrote: On Fri, Nov 14, 2014 at 10:15 AM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, Reimar

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 10:50 AM, Reimar Grabowski reimg...@web.de wrote: On Fri, 14 Nov 2014 14:15:08 +0100 (CET) Michael Van Canneyt mich...@freepascal.org wrote: Connections for databases that have lastinsertID you can call the method created for this: Function GetInsertID: int64;

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 10:40 AM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, silvioprog wrote: On Fri, Nov 14, 2014 at 10:15 AM, Michael Van Canneyt mich...@freepascal.org wrote: [...] Connections for databases that have lastinsertID you can call the

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Martin Schreiber
On Friday 14 November 2014 15:11:30 Michael Van Canneyt wrote: The idea is to add [pfRefresh] to providerflags. When doing an insert, the fields with this flag will be added to the RETURNING clause and used to update the buffer. I suggest [pfRefreshInsert,pfRefreshUpdate] as in MSEgui. MSEgui

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Marcos Douglas
On Fri, Nov 14, 2014 at 11:11 AM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, Marcos Douglas wrote: On Fri, Nov 14, 2014 at 10:39 AM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, Marcos Douglas wrote: On Fri, Nov 14, 2014 at 10:15

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 11:11 AM, Michael Van Canneyt mich...@freepascal.org wrote: [...] By the very nature of the problem: GetLastAutoIncValue simply cannot be implemented in general. In firebird, postgres, these values are generated using a generator/sequence. You don't know the name of

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Michael Van Canneyt
On Fri, 14 Nov 2014, Martin Schreiber wrote: On Friday 14 November 2014 15:11:30 Michael Van Canneyt wrote: The idea is to add [pfRefresh] to providerflags. When doing an insert, the fields with this flag will be added to the RETURNING clause and used to update the buffer. I suggest

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Michael Van Canneyt
On Fri, 14 Nov 2014, Marcos Douglas wrote: By the very nature of the problem: GetLastAutoIncValue simply cannot be implemented in general. In firebird, postgres, these values are generated using a generator/sequence. ...as well as could have a trigger for these cases, encapsulating the

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread luiz americo pereira camara
2014-11-14 11:43 GMT-03:00 Michael Van Canneyt mich...@freepascal.org: On Fri, 14 Nov 2014, Marcos Douglas wrote: This RETURNING clause works for all DBMS? AFAIK Only sqlite does not (maybe it does today). But that is not a DBMS :-) MySQL also does not implement it This is the

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Michael Van Canneyt
On Fri, 14 Nov 2014, silvioprog wrote: On Fri, Nov 14, 2014 at 11:11 AM, Michael Van Canneyt mich...@freepascal.org wrote: [...] By the very nature of the problem: GetLastAutoIncValue simply cannot be implemented in general. In firebird, postgres, these values are generated

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Michael Van Canneyt
On Fri, 14 Nov 2014, luiz americo pereira camara wrote: 2014-11-14 11:43 GMT-03:00 Michael Van Canneyt mich...@freepascal.org: On Fri, 14 Nov 2014, Marcos Douglas wrote: This RETURNING clause works for all DBMS? AFAIK Only sqlite does not (maybe it does today).

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 11:43 AM, Michael Van Canneyt mich...@freepascal.org wrote: [...] AFAIK Only sqlite does not (maybe it does today). But that is not a DBMS :-) Yes. It would be nice execute the last_insert_rowid() to return it in the same cursor (AFAIK, Android SDK use this mechanism

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 11:47 AM, Michael Van Canneyt mich...@freepascal.org wrote: [...] I was planning some fallback mechanism, yes. And a class function SupportReturningClause : Boolean or something similar. Or maybe TDBCapability = (lastID,returningclause); TDBCapabilities = set of

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 12:49 PM, silvioprog silviop...@gmail.com wrote: On Fri, Nov 14, 2014 at 11:43 AM, Michael Van Canneyt mich...@freepascal.org wrote: [...] AFAIK Only sqlite does not (maybe it does today). But that is not a DBMS :-) Yes. It would be nice execute the

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Reimar Grabowski
On Fri, 14 Nov 2014 12:49:44 -0300 silvioprog silviop...@gmail.com wrote: snip This means that the value returned by the function to a given client is the first AUTO_INCREMENT value generated for most recent statement affecting an AUTO_INCREMENT column *by that client*. Just to clarify, the

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Marcos Douglas
On Fri, Nov 14, 2014 at 11:43 AM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, Marcos Douglas wrote: By the very nature of the problem: GetLastAutoIncValue simply cannot be implemented in general. In firebird, postgres, these values are generated using a

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Michael Van Canneyt
On Fri, 14 Nov 2014, Marcos Douglas wrote: Your remarks sound like maybe you don't understand/know exactly what RETURNING does ? It was invented exactly to deal with such things. AFAIK RETURNING is a SQL clause. I know that but I never used before. You tell me SQLdb will use RETURNING

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Marcos Douglas
On Fri, Nov 14, 2014 at 2:11 PM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, Marcos Douglas wrote: Your remarks sound like maybe you don't understand/know exactly what RETURNING does ? It was invented exactly to deal with such things. AFAIK RETURNING is a SQL

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Reimar Grabowski
On Fri, 14 Nov 2014 14:50:20 +0100 Reimar Grabowski reimg...@web.de wrote: On Fri, 14 Nov 2014 14:15:08 +0100 (CET) Michael Van Canneyt mich...@freepascal.org wrote: Connections for databases that have lastinsertID you can call the method created for this: Function GetInsertID:

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Michael Van Canneyt
On Fri, 14 Nov 2014, Reimar Grabowski wrote: On Fri, 14 Nov 2014 14:50:20 +0100 Reimar Grabowski reimg...@web.de wrote: On Fri, 14 Nov 2014 14:15:08 +0100 (CET) Michael Van Canneyt mich...@freepascal.org wrote: Connections for databases that have lastinsertID you can call the method

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Michael Van Canneyt
On Fri, 14 Nov 2014, Marcos Douglas wrote: specify a refresh SQL statement. (coincidentally: these are the engines that use autoInc type fields instead of sequences) This option, to specify a SQL statement, is the programmer that write the SQL? This should come from driver, don't? If

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 3:23 PM, Michael Van Canneyt mich...@freepascal.org wrote: On Fri, 14 Nov 2014, Reimar Grabowski wrote: On Fri, 14 Nov 2014 14:50:20 +0100 Reimar Grabowski reimg...@web.de wrote: On Fri, 14 Nov 2014 14:15:08 +0100 (CET) Michael Van Canneyt mich...@freepascal.org

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Marco van de Voort
On Fri, Nov 14, 2014 at 03:11:30PM +0100, Michael Van Canneyt wrote: By the very nature of the problem: GetLastAutoIncValue simply cannot be implemented in general. In firebird, postgres, (and Oracle afaik) these values are generated using a generator/sequence. You don't know the name

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread silvioprog
On Fri, Nov 14, 2014 at 8:32 PM, Marco van de Voort mar...@stack.nl wrote: On Fri, Nov 14, 2014 at 03:11:30PM +0100, Michael Van Canneyt wrote: By the very nature of the problem: GetLastAutoIncValue simply cannot be implemented in general. In firebird, postgres, (and Oracle afaik)

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-14 Thread Reimar Grabowski
On Fri, 14 Nov 2014 19:23:50 +0100 (CET) Michael Van Canneyt mich...@freepascal.org wrote: a) Did you do an insert right before the call to GetInsertID ? b) Is the transaction active after the insert ? c) The connection transaction should be the same as the transaction of the insert. Got

[Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-13 Thread Reimar Grabowski
Hi, first of all I am new to using Lazarus/FPC for database communication. I have set up my database connection, transaction and queries via the Object Inspector and all is working as it should. But I have a little problem getting the PK value of a newly inserted record (the PK field is an

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-13 Thread silvioprog
On Thu, Nov 13, 2014 at 11:07 AM, Reimar Grabowski reimg...@web.de wrote: Hi, first of all I am new to using Lazarus/FPC for database communication. I have set up my database connection, transaction and queries via the Object Inspector and all is working as it should. But I have a little

Re: [Lazarus] TSQLQuery: Getting autoincremented ID value after insert (MySQL)

2014-11-13 Thread Marcos Douglas
On Thu, Nov 13, 2014 at 11:07 AM, Reimar Grabowski reimg...@web.de wrote: Hi, first of all I am new to using Lazarus/FPC for database communication. I have set up my database connection, transaction and queries via the Object Inspector and all is working as it should. But I have a little

[Lazarus] TSQLQuery Error Database not assigned.

2012-12-26 Thread Giuliano Colla
I'm trying to familiarize with MySql components, using mysql 5.1. I downloaded the TryMySql example linked from the Wiki page, I've changed TMySQL50Connection to TMySQL51Connection, and set in SQLQuery ParseSQL=False and ReadOnly=true, as suggested, but when I try to run it, the connect to

Re: [Lazarus] TSQLQuery Error Database not assigned.

2012-12-26 Thread Michael Van Canneyt
On Wed, 26 Dec 2012, Giuliano Colla wrote: I'm trying to familiarize with MySql components, using mysql 5.1. I downloaded the TryMySql example linked from the Wiki page, I've changed TMySQL50Connection to TMySQL51Connection, and set in SQLQuery ParseSQL=False and ReadOnly=true, as

Re: [Lazarus] TSQLQuery Error Database not assigned.

2012-12-26 Thread William Oliveira Ferreira
Another point is add a transaction on your project and assign it to sqlconnection... At least, i never connected without a transaction Em 26/12/2012 12:37, Michael Van Canneyt mich...@freepascal.org escreveu: On Wed, 26 Dec 2012, Giuliano Colla wrote: I'm trying to familiarize with

Re: [Lazarus] TSQLQuery Error Database not assigned.

2012-12-26 Thread Giuliano Colla
Il 26/12/2012 15:53, William Oliveira Ferreira ha scritto: Another point is add a transaction on your project and assign it to sqlconnection... At least, i never connected without a transaction Did you set SQLQuery1.Database:=MySQLConnection1; ? Also 'Show databases' will - to

[Lazarus] TSQLQuery limited to 255 characters in Unicode

2012-04-25 Thread Hugues Moisy
Hi all, I'm using TSQLQuery on SQLite in order to manipulation very long unicode strings (in tibetan). On inserting there is no problem, everything in inserted correctly in the database, using this code, containing a SQLquery : procedure ExecuteSQL(pRequete: string; pCommit: boolean);

[Lazarus] TSQLQuery state doesn't change after TSQLQuery.Open

2011-08-10 Thread William Oliveira Ferreira
Does it heappens to anyone? here, any of mysql TSQLQuery.Open changed TSQLQuery.State William de Oliveira Ferreira Bacharel em Sistemas de Informação -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org

Re: [Lazarus] TSQLQuery and creating a new record

2010-05-18 Thread Joost van der Sluis
On Mon, 2010-05-17 at 12:49 -0500, Albert Zuurbier wrote: would like to discuss (and hopefully learn) about other things I found. It always amazes me how people can have huge problems with the most simple things. It probably means that there

Re: [Lazarus] TSQLQuery and creating a new record

2010-05-18 Thread Albert Zuurbier
IT WORKS! I definitively vote for documentation. Now, documentation is where I can do something. I cannot add anything to the development of TSQLQuery itself, so much is made more than clear. But, I am happy that the component works the way I expected it to work. Glad to hear. But if you're

Re: [Lazarus] TSQLQuery and creating a new record

2010-05-17 Thread Joost van der Sluis
On Sun, 2010-05-16 at 15:46 -0500, Albert Zuurbier wrote: Over the past few days I have tried creating and editing new records with the TSQLQuery component. I succeeded, but with quite a workaround. As stated in bug report 0016076 (not authored by me) TSQLQuery gives errors if you try to

Re: [Lazarus] TSQLQuery and creating a new record

2010-05-17 Thread Albert Zuurbier
would like to discuss (and hopefully learn) about other things I found. It always amazes me how people can have huge problems with the most simple things. It probably means that there has to be something wrong, somewhere. (Documentation?) Are you familiar with datasets in

[Lazarus] TSQLQuery and creating a new record

2010-05-16 Thread Albert Zuurbier
Over the past few days I have tried creating and editing new records with the TSQLQuery component. I succeeded, but with quite a workaround. As stated in bug report 0016076 (not authored by me) TSQLQuery gives errors if you try to create a new record and think TSQLQuery would all handle it. The