Subject | Re: [IBO] Problem with parameters in query |
---|---|
Author | Svein Erling Tysvær |
Post date | 2017-08-31T07:43:41Z |
This is probably not much help, Helmut, but some years ago I tried using the same parameter to compare against a CHAR and a VARCHAR field. It didn't work and I learnt that parameters in Firebird are by reference, not by name. IBO tries to hide that by making identical references be considered a single parameter (and I think Jason fixed the CHAR/VARCHAR issue shortly after), but it was enough for me to generally stop writing:
SELECT <whatever>
FROM MyTable
WHERE Field1 = :MyParam
OR Field2 = :MyParam
and rather write things like:
WITH TMP(MyTmpField) AS
(SELECT CAST(:MyParam AS <whatever>) FROM RDB$DATABASE)
SELECT <whatever>
FROM MyTable M
JOIN TMP T ON M.MyTmpField = T.Field1
OR M.MyTmpField = T.Field2
This change will not help you today (of course), but writing your SQL so that it really only has one direct reference to each parameter would avoid potential future pitfalls like the one you're experiencing today.
Set