Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
- Posts: 52
- Joined: Mon 24 Mar 2008 13:22
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
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
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.
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.