Problem with identity fields in SDAC 4.X ver. prof.

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Sergio Bertolotti
Posts: 54
Joined: Tue 02 May 2006 12:03
Location: Italy

Problem with identity fields in SDAC 4.X ver. prof.

Post by Sergio Bertolotti » Sat 31 Mar 2007 15:26

Dear support,

I precedently use SDAC 3.x with Microsoft SQL Express 2005 in italian with service pack 2 and Borland Delphi 7 ver. professional.
I note this problem.
With SDAC 3.x if I have a table with an identity field, for example :

CREATE TABLE [dbo].[sergio] (
[CONTA] int IDENTITY(1, 1) NOT NULL,
[DEMO] varchar(30) COLLATE Latin1_General_CI_AS,
CONSTRAINT [sergio_pk] PRIMARY KEY CLUSTERED ([CONTA]),
UNIQUE ([CONTA])
)
ON [PRIMARY]

when I generate SQL insert in my TMSQuery I obtain the following
statement :

INSERT INTO sergio
(DEMO)
VALUES
(:DEMO)
SET :CONTA = SCOPE_IDENTITY()

Then I use TCustomDADataSet.BeforeUpdateExecute event to set parameter type to ptInputOutput in my insert statement.

For example:
procedure TForm1.MSQuery1BeforeUpdateExecute(Sender: TCustomMSDataSet;
StatementTypes: TStatementTypes; Params: TMSParams);
begin
if stInsert in StatementTypes then
Params.ParamByName('CONTA').ParamType := ptInputOutput;
end;

and to set property TCustomDADataSet.Options.ReturnParams to True.

Now, with SDAC 4.x when I generate SQL Insert I obtain :

INSERT INTO sergio
(DEMO)
VALUES
(:DEMO)

without SET :CONTA = SCOPE_IDENTITY(), and I can't retrieve value for field conta with MSQuery1BeforeUpdateExecute.

There is a new option/method for doing/obtain this value or this is a bug ?

Best regards.
Sergio B.

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Mon 02 Apr 2007 11:27

Thank you for information.
We have reproduced the problem and fixed it.
This fix will be included in the next build of SDAC 4.
Last edited by Jackson on Mon 02 Apr 2007 11:59, edited 1 time in total.

Sergio Bertolotti
Posts: 54
Joined: Tue 02 May 2006 12:03
Location: Italy

Post by Sergio Bertolotti » Mon 02 Apr 2007 11:34

Dear EvgeniyM,

many thank's for your interesting.

I use in many points of my code this method for retrieving data in input.

When do you plan to releas this update to SDAC 4 ?

Best regards.
Sergio B.

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Mon 02 Apr 2007 12:00

New build of SDAC 4 will be available in about one week.

Post Reply