Autoinc primary key not refreshed after post
Posted: 02.06.2008, 04:40
I'm having trouble with TZUpdateSQL on Delphi 7 + Zeos 6.6.2 RC2 + SQLite 3.5.9.
I have an autoincrement primary key field on the table I want to update. But I don't know what kind of RefreshSQL I should give to the ZUpdateSQL so the primary key field automatically retrieved after a post (and the record pointer stays on the record I have just posted).
Here is the reproduction of my situation:
the table
---------
CREATE TABLE [mytable] (
[id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[name] VARCHAR(20));
the ZQuery
----------
object ZQuery1: TZQuery
Connection = ZConnection1
UpdateObject = ZUpdateSQL1
SQL.Strings = (
'select * from mytable'
'order by name')
Params = <>
SequenceField = 'id'
Left = 64
Top = 16
end
the ZUpdateSQL
--------------
object ZUpdateSQL1: TZUpdateSQL
DeleteSQL.Strings = (
'DELETE FROM mytable'
'WHERE'
' ((id IS NULL AND :OLD_id IS NULL) OR (id = :OLD_id))')
InsertSQL.Strings = (
'INSERT INTO mytable'
' (name)'
'VALUES'
' (:name)')
ModifySQL.Strings = (
'UPDATE mytable SET'
' mytable.name = :name'
'WHERE'
' ((id IS NULL AND :OLD_id IS NULL) OR (id = :OLD_id))')
UseSequenceFieldForRefreshSQL = True
Left = 160
Top = 16
ParamData = <
item
DataType = ftUnknown
Name = 'name'
ParamType = ptUnknown
end
item
DataType = ftUnknown
Name = 'OLD_id'
ParamType = ptUnknown
end>
end
I have tried to fill the RefreshSQL with these lines but all failed:
- select * from mytable where id = :id
- select * from mytable where id = :OLD_id
- select * from mytable where id = :NEW_id
I hope someone could help me. Thank you.
I have an autoincrement primary key field on the table I want to update. But I don't know what kind of RefreshSQL I should give to the ZUpdateSQL so the primary key field automatically retrieved after a post (and the record pointer stays on the record I have just posted).
Here is the reproduction of my situation:
the table
---------
CREATE TABLE [mytable] (
[id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[name] VARCHAR(20));
the ZQuery
----------
object ZQuery1: TZQuery
Connection = ZConnection1
UpdateObject = ZUpdateSQL1
SQL.Strings = (
'select * from mytable'
'order by name')
Params = <>
SequenceField = 'id'
Left = 64
Top = 16
end
the ZUpdateSQL
--------------
object ZUpdateSQL1: TZUpdateSQL
DeleteSQL.Strings = (
'DELETE FROM mytable'
'WHERE'
' ((id IS NULL AND :OLD_id IS NULL) OR (id = :OLD_id))')
InsertSQL.Strings = (
'INSERT INTO mytable'
' (name)'
'VALUES'
' (:name)')
ModifySQL.Strings = (
'UPDATE mytable SET'
' mytable.name = :name'
'WHERE'
' ((id IS NULL AND :OLD_id IS NULL) OR (id = :OLD_id))')
UseSequenceFieldForRefreshSQL = True
Left = 160
Top = 16
ParamData = <
item
DataType = ftUnknown
Name = 'name'
ParamType = ptUnknown
end
item
DataType = ftUnknown
Name = 'OLD_id'
ParamType = ptUnknown
end>
end
I have tried to fill the RefreshSQL with these lines but all failed:
- select * from mytable where id = :id
- select * from mytable where id = :OLD_id
- select * from mytable where id = :NEW_id
I hope someone could help me. Thank you.