Question

I am using Delphi 2010 and UIB to access a Firebird database.

I am trying to run the Query

    SELECT
        RECID
    FROM TABLE
    WHERE ((:DX = '') OR (DX=:DX))
        AND ((:POSTCODE='') OR (POSTCODE=:POSTCODE))

Note, that I am using each named parameter twice in the statement.

When I prepare it in a TUIBQuery I get ParamCount=2 and two parameters named DX. When I trace the code I see TSQLParams.Parse passing over the my SQL and calling AddFieldA four times. I can see that duplicates are recognized and added to the end of FXSQLDA, but FParamCount is not incremented.

As a temporary dumb fix I have added such an increment and I now get (DX, DX, POSTCODE, POSTCODE) as parameter-list. That sort of works.

Questions:

  • Is the sort of parameter-reuse I am attempting supported by Firebird?
  • By UIB?
  • Is my fix viable?
  • Are there better fixes?

No correct solution

OTHER TIPS

Firebird itself does not support named parameters in dynamic SQL (it does in procedural SQL). Firebird only supports positional parameters.

So it is your driver that translates named parameters to positional.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top