Results 1 to 5 of 5

Thread: The ? placeholder in SQL

  1. #1
    New Member
    Join Date
    Jul 2010
    Posts
    8

    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. #2
    Super Moderator
    Join Date
    Feb 2010
    Posts
    186

    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.

  3. #3
    New Member
    Join Date
    Jul 2010
    Posts
    8

    Thanks

    Thanks Ryan.

  4. #4
    New Member
    Join Date
    Nov 2016
    Posts
    3
    Hi Ryan,

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

  5. #5
    Super Moderator
    Join Date
    Dec 2011
    Posts
    224
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •