In my Query i get the resultset from two joined tables.
The rows are displayed in a DBGrid.
How can i update the fields of BOTH tables?
How to update fields from joined tables
Hello,
I found that in sdac this not work, but in SQL Management studio all ok
Insert statment in query statments editor:
problem what scope_identity doesn't return any value from db
D2009, SDAC 4.70.0.48
I found that in sdac this not work, but in SQL Management studio all ok
Insert statment in query statments editor:
Code: Select all
INSERT INTO [table1]
([value1], [value2], [value3])
VALUES (:[value1], :[value2], :[value3])
SET :[value0] = SCOPE_IDENTITY()
INSERT INTO [table2]
([value0], [value4], [value5], [value6])
VALUES (:[value0], :[value4], :[value5], :[value6])
D2009, SDAC 4.70.0.48
To solve the problem you should use the following SQL:
Also you should set ParamType of the value0 parameter to ptInputOutput in the TMSQuery.BeforeUpdateExecute event handler, like this:
Code: Select all
INSERT INTO [table1]
([value1], [value2], [value3])
VALUES (:[value1], :[value2], :[value3])
SET :[value0] = SCOPE_IDENTITY()
INSERT INTO [table2]
([value0], [value4], [value5], [value6])
VALUES (SCOPE_IDENTITY(), :[value4], :[value5], :[value6])
Code: Select all
Params.ParamByName('value0').ParamType := ptInputOutput;