【发布时间】:2013-12-24 03:26:27
【问题描述】:
这是 (*.sql) 文件中的示例更新脚本。我必须从下面显示的输出中的 shell 脚本/sql 脚本中提取 oracle 表名。另外我附上下面的源代码。我试图通过 awk 命令来完成,
代码:
awk -F'[=&? ]' '{for (i=1;i<NF;i++) if ($i == "from") print (i+1) }' $FILE
输出:
UPDATE|EVENT.SEASONAL_EVENT_SKU
SELECT|PLANOGRAM_SKU
SELECT|PLANOGRAM_VERSION
SELECT|SEASONAL_EVENT_SKU
示例脚本:
update EVENT.SEASONAL_EVENT_SKU
set SEAS_SKU_IND = 'Y'
where SKU_NBR in ( select distinct sku_nbr
from
(
select a.sku_nbr
from PLANOGRAM_SKU a,
PLANOGRAM_VERSION b
where a.plano_nbr between 9000 and 9999
and a.plano_nbr = b.plano_nbr
and a.plano_version_id = b.plano_version_id
and b.seas_plano_ind = 'Y'
and a.sku_nbr not in ( select d.sku_nbr
from PLANOGRAM_SKU d,
PLANOGRAM_VERSION e
where d.plano_nbr between 9000 and 9999
and d.plano_nbr = e.plano_nbr
and d.plano_version_id = e.plano_version_id
and e.seas_plano_ind <> 'Y')
union all
select f.sku_nbr
from SEASONAL_EVENT_SKU f
where f.sku_nbr not in ( select g.sku_nbr
from PLANOGRAM_SKU g
where g.plano_nbr between 9000 and 9999 )));
COMMIT;
让我知道对“n”个脚本执行此操作的更好方法。谢谢。
【问题讨论】: