0

I want to create a table with a named query, but on another database. And get the name of the database with a parameter.

I'm trying to do it like this

<sql-query name="createStatement">
    <query-param name="dbName" type="string"/>
    CREATE TABLE `:dbName`.`test` (
      `customer_id` int(11) NOT NULL AUTO_INCREMENT,
      PRIMARY KEY (`customer_id`)
    );
</sql-query>

But I'm getting the Unknown Parameter name Exception. I have tried adding spaces or remove the ` character, but still not working.

What is the correct way to set this parameter?

1 Answer 1

1

Query parameters cannot be used for database identifiers. Nor for table identifiers, column identifiers, or SQL keywords or expressions.

Query parameters can be used only for a single lexical element, and only where you could otherwise use a constant data value, i.e. a quoted string literal, quoted date/time literal, or a numeric literal.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.