I have a ZQuery1 with ZUpdateSQL1.
I want to use Firebird merge statement in ZUpdateSQL.ModifySQL.
Take a look at these statements:
1:
Code: Select all
update table1
set field2 = :field2
where id = :old_id
2:
Code: Select all
merge into table1 x
using (select :old_id as id, :field2 as f2 from rdb$database) y
on x.id = y.id
when matched then update set field2 = y.f2
It seems to me that ZUpdateSQL doesn't know how to substitute parameters with values.SQL Error: Dynamic SQL Error SQL error code = -804 Data type unknown. Error Code: -804. can't format message 13:196 -- message file C:\Windows\firebird.msg not found The SQL: merge into table1 x using (select ? as id, ? as f2 from rdb$database) y on x.id = y.id when matched then update set field2 = y.f2; .
Why? Shouldn't ZUpdateSQL just replace parameters with values and send the statement to database? With substituted values this merge statement works well (I checked in FlameRobin).
Of course, for the simple example I have shown here, in real application I would use the "update" variant, not "merge". But I have complex sql query and using merge is what I need there. This is just simple example which describes the problem.