Page 1 of 1

Problem with Identity field in MSQuery

Posted: Fri 21 Dec 2007 09:29
by Dimonis
Delphi 6 – MS SQL Server 2000 – SDAC 4.3.0.13

Hi. I have table that has created with Script:

Create Table Istrab (
ID_Istrab BigInt Identity(1,1) not null, -- ID èñòîðèè "ðàáîòàåò
Fio_GUID Varchar(38) null, -- GUID êëèåíòà
Kodsost Tinyint null, -- êîä ñîñòîÿíèÿ
Dhom Datetime null, -- äàòà íà÷àëà "ðàáîòàåò"
Dend Datetime null, -- äàòà êîíöà "ðàáîòàåò"
)
Create NonClustered Index Istrab_ID On Istrab(ID_Istrab)

For access to this table uses MSQuery (has name Rabuc) that placed properties:

SQL:
Select ID_Istrab, Fio_GUID, Kodsost, Dhom, Dend From Istrab Where Istrab.Fio_GUID=:p1
Order by Istrab.ID_Istrab

SQLDelete:
DELETE FROM Istrab WHERE ID_Istrab=:Old_ID_Istrab

SQLInsert:
INSERT INTO Istrab (Fio_GUID, Kodsost, Dhom, Dend) VALUES (:Fio_GUID, :Kodsost, :Dhom, :Dend)

SQLRefresh:
Select ID_Istrab, Fio_GUID, Kodsost, Dhom, Dend,
Forist.NaimForist
From Istrab left join Forist on Istrab.Kodsost=Forist.Kod
Where ID_Istrab=:ID_Istrab

SQLUpdate:
UPDATE Istrab
SET Kodsost=:Kodsost, Dhom=:Dhom, Dend=:Dend
WHERE ID_Istrab=:ID_Istrab

Application has Code:
Rabuc.Insert;
RabucFio_GUID.Value:=’18’
Rabuc.Post;

After execute this code application say that RabucFio_GUID.AsString is ‘18’ but RabucID_Istrab.AsString=’0’ in inserted record.

I have a question – how can make that after Insert in application can see Identity field.

Thanks.

Posted: Fri 21 Dec 2007 16:22
by Antaeus
A similar question was recently discussed at this thread. Please take a look at it.