Page 1 of 1

MSQuery.Insert & newsequentialid()

Posted: Wed 05 Sep 2012 09:36
by Alexander_73
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?

Re: MSQuery.Insert & newsequentialid()

Posted: Wed 05 Sep 2012 13:55
by AndreyZ
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.

Re: MSQuery.Insert & newsequentialid()

Posted: Thu 06 Sep 2012 13:40
by Alexander_73
Thanks, I'll prolong the license and wait for next builds.

Re: MSQuery.Insert & newsequentialid()

Posted: Wed 12 Sep 2012 07:42
by Alexander_73
New version of SDAC released, but this error still raised... :(

Re: MSQuery.Insert & newsequentialid()

Posted: Wed 12 Sep 2012 09:18
by AndreyZ
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 .