Forum: Building VoltDB Applications

Post: The ? placeholder in SQL

The ? placeholder in SQL
Jul 13, 2010
I am not able to use the ? placeholder in certain places in my SQLStmt's.

For example:

The SQL statement
insert into test (?) values (?);

throws the error

[java] 548 [main] ERROR COMPILER - Failed to plan for stmt type(tbl_test_ins) insert into test (?) values (?); Error: "unexpected token: ?"

I figured out that the first ? is what's throwing that error
and the SQL statment

select ? from test

throws the error

[java] 498 [main] ERROR COMPILER - Failed to plan for stmt type(tbl_test) select ? from test Error: "data type cast needed for parameter or null literal"


select * from ?

throws the error

[java] 545 [main] ERROR COMPILER - Failed to plan for stmt type(tbl_test) select * from ? Error: "unexpected token: ?"

Am I doing something wrong? Will further support of the ? placeholder be implement in the future?
Supported parameter use.
Jul 13, 2010

VoltDB supports parameters as placeholders for varchars, integers (of all sizes), decimals and floats. The '?' turns what would be a literal value into a parameter.

Table names, column names, SQL tokens (like "order by"), etc., can not be parametrized. These need to provided in advance to VoltDB in order to create a prepared plan for the statement's execution.

Jul 13, 2010
Thanks Ryan.
Feb 10, 2017
Hi Ryan,

We are using VoltDB 6.3 . Does VoltDB support parametrized for SQL token "Order by" in any current or future release.
Feb 10, 2017

We have no plans to support parameterized ORDER BY columns. The ORDER BY affects the plan for the query, which cannot change. In some cases it may use part of an index for the ORDER BY and avoid an additional SORT operation. The parameters have to be essentially stand-ins for constant values where regardless of the value submitted the plan for the query is the same.

Best regards,