Search code examples
sqloracledelphizeos

How to use TQuery with Oracle SQL syntax for variable assignments and Params?


In a regular Query on Oracle SQL we could use:

var_user VARCHAR2(256) := 'eduard'
select * from a_table where user_name = var_user

If I use this code in Delphi's TQuery.SQL.Text I get the error Incorrect Token Followed By ":"..

I believe it is happening because Delphi uses : symbol in this case to specify a parameter inside TQuery.SQL.Text to be replaced by the values set at TQuery.Params[].

What I really want to do is SomeVarInsideSQL := :MyParam and I can't because of that error. What should I do? (delphi-xe3-zeoslib)


Solution

  • You need to escape : to :: if you have to bypass specific TQuery Parameter parsing.