MSQuery.Insert & newsequentialid()

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Alexander_73
Posts: 52
Joined: Mon 24 Mar 2008 13:22

MSQuery.Insert & newsequentialid()

Post by Alexander_73 » Wed 05 Sep 2012 09:36

Hi,

RAD Studio 2007, SDAC 6.1.3.

Code: Select all

CREATE TABLE [mb_suprt](
	[MsgID] [int] NOT NULL,
	[Subject] [nvarchar](250) NULL,
	[Message] [nvarchar](max) NULL,
	[SeqID] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_mb_suprt] PRIMARY KEY CLUSTERED 
(
	[MsgID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [mb_suprt] ADD  CONSTRAINT [DF_mb_suprt_SeqID]  DEFAULT (newsequentialid()) FOR [SeqID]
An object of TMSQuery:

Code: Select all

 Q.SQL.Text:='SELECT * FROM mb_suprt WHERE MsgID='+MsgID;
 Q.UpdatingTable:=mb_suprt;
 Q.KeyFields:='MsgID';
 Q.Open;
 [b]Q.Insert;[/b] // this row raises exception
...
The marked row raises an exception EMSError with message built-in function newsequentialid() only for construction CREATE TABLE or ALTER TABLE...

Why there is this error?

AndreyZ

Re: MSQuery.Insert & newsequentialid()

Post by AndreyZ » Wed 05 Sep 2012 13:55

Hello,

Thank you for the information. This error can occur if you set the TMSQuery.Options.DefaultValues property to True. In this case, SDAC tries to obtain the default values from the server, which in case of using newsequentialid() is incorrect. We will fix this error in one of the next SDAC builds. As a workaround, you can set the TMSQuery.Options.DefaultValues property to False.

Alexander_73
Posts: 52
Joined: Mon 24 Mar 2008 13:22

Re: MSQuery.Insert & newsequentialid()

Post by Alexander_73 » Thu 06 Sep 2012 13:40

Thanks, I'll prolong the license and wait for next builds.

Alexander_73
Posts: 52
Joined: Mon 24 Mar 2008 13:22

Re: MSQuery.Insert & newsequentialid()

Post by Alexander_73 » Wed 12 Sep 2012 07:42

New version of SDAC released, but this error still raised... :(

AndreyZ

Re: MSQuery.Insert & newsequentialid()

Post by AndreyZ » Wed 12 Sep 2012 09:18

We did not include the fix to this problem in the latest SDAC version 6.5.9. This happened because a lot of our users were waiting for RAD Studio XE3 support, and we did not have time to perform all our tests again with this fix. We will include this fix to the next SDAC build.
If you need this fix as soon as possible, we can send you a custom SDAC build with this fix. Please send your SDAC license number to andreyz*devart*com .

Post Reply