【发布时间】:2020-10-15 14:13:25
【问题描述】:
目前,我在 DataStage 中有一个序列作业。
这是流程:
StartLoop Activity --> UserVariables Activity --> Job Activity --> Execute Command --> Endloop Activity
该作业将每 30 分钟(上午 8 点 - 晚上 8 点)运行一次以获取真实数据。第一个循环迭代将加载从前一天晚上 8 点到当天早上 8 点的数据,其他循环将加载最近 30 分钟内发生的数据。
UserVariables Activity 是传递变量(SQL 语句)来过滤在 Job Activity 中获取的数据。第一次迭代 UserVariables 将变量 A(SQL 语句 1)传递给 Job Activity,从第二次迭代开始,它将变量 B(SQL 语句 2)传递给 Job Activity。
执行命令 我目前将作业的“睡眠 1800”命令设置为睡眠 30 分钟以结束循环的迭代。但我现在意识到它受到每次迭代的运行时间的影响。因此,在我对 shell 脚本一无所知的情况下,我已经搜索了解决方案并让这个文件进入休眠状态,直到 30 或 00 分钟的特定时间(延迟 0-1 分钟,但没关系)。
shell 脚本如下,我在我的系统上运行良好,但没有成功将其作为工作的一部分。
#!/bin/bash
minute=$(date +%M)
num_1=30
num_2=60
if [ $minute -le 30 ];
then
wait=$((($num_1 - $minute)*$num_2))
sleep $wait
fi
if [ $minute -gt 30 ];
then
wait=$((($num_2 - $minute)*$num_2))
sleep $wait
fi
我现在面临 2 个问题,需要您的帮助。
- 作业使用下面的变量 A 运行第一次迭代:
select * from my_table where created_date between trunc(sysdate-1) + 20/24 and trunc(sysdate) + 8/24;
但从第二次迭代开始,作业活动失败,变量 B 如下:
select * from my_table where created_date between trunc(sysdate-1/48, 'hh') + 30*trunc(to_number(to_char(sysdate-1/48,'MI'))/30)/1440 and trunc(sysdate, 'hh') + 30*trunc(to_number(to_char(sysdate,'MI'))/30)/1440;
在并行作业中,日志说:
INPUT,0: The following SQL statement failed: select * from my_table where created_date between trunc(sysdate-1/48, hh) + 30*trunc(to_number(to_char(sysdate-1/48,MI))/30)/1440 and trunc(sysdate, hh) + 30*trunc(to_number(to_char(sysdate,MI))/30)/1440.
我意识到它可能无法运行并行作业,因为它删除了 hh 和 MI 中的单引号。
是因为当将变量从 UserVariables Activity 传递给 Job Activity 时,该变量将删除所有引号?我该如何解决这个问题?
2. 如何将上面的 shell 脚本作为 Execute Command 或其他阶段的工作的一部分。我已经寻找解决方案,我认为这是关于例行活动之前/之后的 ExecSH。但是从 IBM 页面阅读后,我仍然不知道从哪里开始。
很抱歉在 1 个帖子中添加了 2 个问题,这使得它变得如此之长,但它们彼此之间非常相关,所以如果我将它分成 2 个帖子并且你们需要更多关于它的信息,将需要很多时间来回答。
谢谢!
【问题讨论】: