Skip to content
标签
欢迎扫码关注公众号

Kettle 设置和使用变量

使用场景:从数据库中获取上次执行时间,在之后的转换中使用这个时间。
Kettle Version : 7.1

1. 设置变量

  1. 新建一个转换,添加一个 输入 => 表输入作业 => 设置变量

  2. 修改 表输入 使其查询出想要的时间值

  3. 按住 Shift表输入 拖动到 设置变量

  4. 修改 设置变量

    • 字段名称:表输入 中查询出的字段名
    • 变量名:假设为 LastActionTime
    • 变量活动类型:相当于变量的作用域,有四个选项
      • Valid in the Java Virtual Machine
      • Valid in the parent job
      • Valid in the grand-parent job
      • Valid in the root job
    • Default Value
      • 如果 表输入 没有查询到结果时的默认值(这里设置为 2010/01/01 00:00:00
  5. 点击编辑区左上角的 Run 按钮运行转换

    如果变量的活动类型设置为 parent jobgrand-parent job 会由于找不到这个 job 而报错。

2. 使用变量

貌似不用添加 获取变量 也可以直接使用前面的转换步骤中设置的变量。

  1. 在转换中新增一个 作业 => 获取变量

  2. 修改 获取变量

    • 名称:LastActionTime
    • 变量:${LastActionTime} (可以使用快捷键 Ctrl + Alt + Space 选择变量)
    • 类型:Date
    • 格式:yyyy/MM/dd HH:mm:ss (下拉框可以选择格式)
  3. 在转换中的 SQL 文可以通过如下的方式使用变量(SqlServer)。

    sql
    WHERE ModifyDate >= Cast(SUBSTRING('${LastActionTime}',1,19) AS DATETIME)

    一定要勾选 替换 SQL 语句中的变量

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.