Page 1 of 1

Problem while inserting into TMSQuery.

Posted: Tue 19 Jul 2005 11:32
by NG_2005
Hi!
I have Delphi6+TMSQuery+MSSQL7.
CursorType=ctKeyset
FetchAll=True
UpdatingTable=DOCBODIES
SQL='SELECT B.PartID,B.LineTS,B.ID,B.OBJECTID, B.Val, B.Price, B.VAL,
B.Price as Amount, o.assortimentname as name
FROM DOCBODIES B
LEFT JOIN OBJECTS O ON B.ObjectID=O.ID WHERE B.ID=:ID
order by b.objectid'
I have one record in [docbodies] and try to add one.
I was call
MSQuery1.insert
...
MSQuery1.post

and inserted string was disappear from my grid!
it was appear agane after MSQuery1.RefreshRecords
profiler shows this text:
sp_cursor 550133852, 4, 0, N'DOCBODIES', 10642, '00001411', 11., 1.00
go
sp_cursorfetch 550133852, 16, 2, 1
go
sp_cursorfetch 550133852, 16, 1, 1
go
sp_cursorfetch 550133852, 16, 2, 1
go
sp_cursorfetch 550133852, 16, 1, 1
go
sp_cursorfetch 550133852, 16, 1, 1
client calls sp_cursorfetch 3 times (2 on both records and last time only the first)
Answer, please, why does it 3 times and why does the record disappear?

Posted: Wed 20 Jul 2005 11:39
by Ikar
> client calls sp_cursorfetch 3 times (2 on both records and last time only
> the first)


Most probably, it may be optimized. But on working with server cursors it is not important usually. We are planning in the further versions to review algorithm of fetching such cursors.

> why does the record disappear?

It is usual behaviour for ctKeyset. On opening this query an additional table is created at the server where all chosen records are enumerated. A new record is just added into this table. Please refer to MSDN for details.

> I have Delphi6+TMSQuery+MSSQL7.

MSSQL 7 doesn't support server cursors.

Posted: Wed 20 Jul 2005 11:54
by Guest
>MSSQL 7 doesn't support server cursors.
What do you mean?
What is SDAC doing while I'm using ctKeyset on mssql7?

Posted: Wed 20 Jul 2005 14:07
by Ikar
SDAC pass a direction to use this cursor type OLE -> server. According to profiler, you connected to MS SQL Server 2000.

Posted: Thu 21 Jul 2005 07:46
by Guest
I hope, Im not crazy yet. I have been connected MSSQL7 during last three years every day.