可用版本:Dev (3.21) | 最新版 (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11

内联参数

适用于 ✅ 开源版   ✅ 专业版   ✅ 企业版

有时,您可能希望避免呈现绑定变量,同时仍然在 SQL 中使用自定义值。 您可以在此博客文章中查看一些示例原因。 jOOQ 将其称为“内联”绑定值。 当绑定值内联时,它们会在 SQL 中呈现实际值,而不是 JDBC 问号。 可以通过多种方式实现绑定值内联

在所有情况下,您的内联绑定值都将被正确转义,以避免 SQL 语法错误和 SQL 注入。 一些例子

// Use dedicated calls to inline() in order to specify
// single bind values to be rendered as inline values
// --------------------------------------------------
create.select()
      .from(AUTHOR)
      .where(LAST_NAME.eq(inline("Poe")))
      .fetch();

// Or render the whole query with inlined values
// --------------------------------------------------
Settings settings = new Settings()
    .withStatementType(StatementType.STATIC_STATEMENT);

// Add the settings to the Configuration
DSLContext create = DSL.using(connection, SQLDialect.ORACLE, settings);

// Run queries that omit rendering schema names
create.select()
      .from(AUTHOR)
      .where(LAST_NAME.eq("Poe"))
      .fetch();

反馈

您对此页面有任何反馈吗? 我们很乐意听取您的意见!

The jOOQ Logo