mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-26 23:52:09 +02:00
fcl-db: sqldb:
- if there is explicitly supplied RefreshSQL do not try generate returning clause. - if there is explicitly supplied InsertSQL, UpdateSQL set ReturningClause to False as it can lead to "can not open non-select statement" git-svn-id: trunk@30796 -
This commit is contained in:
parent
93802cf5ee
commit
5017d1e6eb
@ -1753,10 +1753,10 @@ Var
|
|||||||
Where : String;
|
Where : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Where:='';
|
|
||||||
Result:=Query.RefreshSQL.Text;
|
Result:=Query.RefreshSQL.Text;
|
||||||
if (Result='') then
|
if (Result='') then
|
||||||
begin
|
begin
|
||||||
|
Where:='';
|
||||||
PF:=RefreshFlags[UpdateKind];
|
PF:=RefreshFlags[UpdateKind];
|
||||||
For F in Query.Fields do
|
For F in Query.Fields do
|
||||||
begin
|
begin
|
||||||
@ -1804,31 +1804,35 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
qry:=Nil;
|
qry:=Nil;
|
||||||
ReturningClause:=(sqSupportReturning in Connoptions) and not (sqoRefreshUsingSelect in Query.Options);
|
ReturningClause:=(sqSupportReturning in ConnOptions) and not (sqoRefreshUsingSelect in Query.Options) and (Query.RefreshSQL.Count=0);
|
||||||
case UpdateKind of
|
case UpdateKind of
|
||||||
ukInsert : begin
|
ukInsert : begin
|
||||||
s := trim(Query.FInsertSQL.Text);
|
s := trim(Query.FInsertSQL.Text);
|
||||||
if s = '' then
|
if s = '' then
|
||||||
s := ConstructInsertSQL(Query,ReturningClause);
|
s := ConstructInsertSQL(Query,ReturningClause)
|
||||||
|
else
|
||||||
|
ReturningClause := False;
|
||||||
qry := InitialiseUpdateStatement(Query,Query.FInsertQry);
|
qry := InitialiseUpdateStatement(Query,Query.FInsertQry);
|
||||||
end;
|
end;
|
||||||
ukModify : begin
|
ukModify : begin
|
||||||
s := trim(Query.FUpdateSQL.Text);
|
s := trim(Query.FUpdateSQL.Text);
|
||||||
if (s='') and (not assigned(Query.FUpdateQry) or (Query.UpdateMode<>upWhereKeyOnly)) then //first time or dynamic where part
|
if (s='') and (not assigned(Query.FUpdateQry) or (Query.UpdateMode<>upWhereKeyOnly)) then //first time or dynamic where part
|
||||||
s := ConstructUpdateSQL(Query,ReturningClause);
|
s := ConstructUpdateSQL(Query,ReturningClause)
|
||||||
|
else
|
||||||
|
ReturningClause := False;
|
||||||
qry := InitialiseUpdateStatement(Query,Query.FUpdateQry);
|
qry := InitialiseUpdateStatement(Query,Query.FUpdateQry);
|
||||||
end;
|
end;
|
||||||
ukDelete : begin
|
ukDelete : begin
|
||||||
s := trim(Query.FDeleteSQL.Text);
|
s := trim(Query.FDeleteSQL.Text);
|
||||||
if (s='') and (not assigned(Query.FDeleteQry) or (Query.UpdateMode<>upWhereKeyOnly)) then
|
if (s='') and (not assigned(Query.FDeleteQry) or (Query.UpdateMode<>upWhereKeyOnly)) then
|
||||||
s := ConstructDeleteSQL(Query);
|
s := ConstructDeleteSQL(Query);
|
||||||
qry := InitialiseUpdateStatement(Query,Query.FDeleteQry);
|
|
||||||
ReturningClause:=False;
|
ReturningClause:=False;
|
||||||
|
qry := InitialiseUpdateStatement(Query,Query.FDeleteQry);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if (s<>'') and (qry.SQL.Text<>s) then
|
if (s<>'') and (qry.SQL.Text<>s) then
|
||||||
qry.SQL.Text:=s; //assign only when changed, to avoid UnPrepare/Prepare
|
qry.SQL.Text:=s; //assign only when changed, to avoid UnPrepare/Prepare
|
||||||
Assert(qry.sql.Text<>'');
|
Assert(qry.SQL.Text<>'');
|
||||||
for x:=0 to Qry.Params.Count-1 do
|
for x:=0 to Qry.Params.Count-1 do
|
||||||
begin
|
begin
|
||||||
P:=Qry.Params[x];
|
P:=Qry.Params[x];
|
||||||
|
Loading…
Reference in New Issue
Block a user