newsequentialid() doesn't return value on MSQuery.Post

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

newsequentialid() doesn't return value on MSQuery.Post

Post by Alexander_73 » Wed 20 Mar 2013 13:00

table:

Code: Select all

CREATE TABLE [dbo].[PrintInfo](
	[ID] [uniqueidentifier] NOT NULL,
	[FirmID] [int] NOT NULL,
	[FirstInvoiceID] [int] NULL,
	[AddDate] [datetime] NOT NULL,
	[Attributes] [int] NOT NULL,
 CONSTRAINT [PK_PrintInfo] PRIMARY KEY CLUSTERED 
(
	[ID] 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 [dbo].[PrintInfo] ADD  CONSTRAINT [DF_PrintInfo_ID]  DEFAULT (newsequentialid()) FOR [ID]
Then field default is newsequentialid() it doesn't return on MSQuery.Post params (both OnBeforeUpdateExecute assigned or not) and raises exception 'field must have value',
but if field default value is newid(), it works OK.

AndreyZ

Re: newsequentialid() doesn't return value on MSQuery.Post

Post by AndreyZ » Wed 20 Mar 2013 13:55

NEWSEQUENTIALID() cannot be referenced in queries, it can only be used with DEFAULT constraints on table columns of type uniqueidentifier. That is why, there is no way to obtain the value of NEWSEQUENTIALID() on the client by queries. As you use NEWSEQUENTIALID() for the PRIMARY KEY field, the only way to obtain its value is to refresh all dataset.
Another solution is to use NEWID() . NEWID() can be referenced in queries, that is why SDAC can obtain its value on the client.

Post Reply