Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-11

SQLDb Query Insert, Update vs SQL

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to ik
ik wrote 5 lines
Hello, How exactly can I make the TSQLQuery work with the Insert query when I do "insert" action on TDBNavigator ? The same question with update.

Either you specify the SQL directly in the InsertSQL, UpdateSQL, DeleteSQL properties.

Do this in the standard way as in Delphi using parameters:

UPDATE MYTABLE SET
Field1 = :Field1,
Field2 = :Field2
WHERE

   MyKeyField = :Old_MyKeyField;

and similar for insert/delete.

or you let SQLDB compute the queries for you, in which case you should set the pfInKey flag of the ProviderFlags property of the key field, and the pfInUpdate flag for all fields that must be updated.

Michael.

Reply by email

ik
to Michael Van Canneyt

I've added the queries into the InsertSQL nd UpdateSQL however it seems like it is using the SQL code and make "it's own" update and insert (I know this because the index is set to not null, and in the select statement I retrieve it, but on Update and Insert it raises an exception that the ID is mandatory and is null).

Ido

http://ik.homelinux.org/

Michael Van Canneyt wrote 36 lines
On Wed, 4 Nov 2009, ik wrote: Hello, > > How exactly can I make the TSQLQuery work with the Insert query when I do > "insert" action on TDBNavigator ? > The same question with update. > Either you specify the SQL directly in the InsertSQL, UpdateSQL, DeleteSQL properties. Do this in the standard way as in Delphi using parameters: UPDATE MYTABLE SET Field1 = :Field1, Field2 = :Field2 WHERE MyKeyField = :Old_MyKeyField; and similar for insert/delete. or you let SQLDB compute the queries for you, in which case you should set the pfInKey flag of the ProviderFlags property of the key field, and the pfInUpdate flag for all fields that must be updated. Michael. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20091104/958d17cc/attachment.html>

Reply by email

JoshyFun
to ik

Hello Lazarus-List,

Wednesday, November 4, 2009, 3:35:14 PM, you wrote:

i> I've added the queries into the InsertSQL nd UpdateSQL however it seems like i> it is using the SQL code and make "it's own" update and insert (I know this i> because the index is set to not null, and in the select statement I retrieve i> it, but on Update and Insert it raises an exception that the ID is mandatory i> and is null).

Update and Insert SQL (custom) requires a quite recent patch, or a fpc 2.0.x (if my memory serves me).

Best regards, JoshyFun

Reply by email

Joost van der Sluis
to JoshyFun
JoshyFun wrote 12 lines
Hello Lazarus-List, Wednesday, November 4, 2009, 3:35:14 PM, you wrote: i> I've added the queries into the InsertSQL nd UpdateSQL however it seems like i> it is using the SQL code and make "it's own" update and insert (I know this i> because the index is set to not null, and in the select statement I retrieve i> it, but on Update and Insert it raises an exception that the ID is mandatory i> and is null). Update and Insert SQL (custom) requires a quite recent patch, or a fpc 2.0.x (if my memory serves me).

That's true. But as a workaround you can set them in code.

Joost.

Reply by email