Announcement

Collapse
No announcement yet.

The ? placeholder in SQL

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • The ? placeholder in SQL

    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"

    and

    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?

  • #2
    Supported parameter use.

    Will,

    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.

    *--Ryan.

    Comment


    • #3
      Thanks

      Thanks Ryan.

      Comment


      • #4
        Hi Ryan,

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

        Comment


        • #5
          Hi,

          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,
          Ben

          Comment

          Working...
          X