今日目标
- [x] 编写shell,插入日志表
- [x] 编写ctl文件,读取多行多列的txt文件
- [ ] 将kettle job转化成纯shell模式
- [ ] 将kettle job转化成纯java模式
日常笔记
-
<<代表下个此为分节符,例如
<<EOF 执行语句 EOF -
一起的命令不能换行,例如
sqlplus fb/fb@orcl <<EOF 执行语句 EOF -
oralce中/时begin end;语句与下一句SQL语句的分隔,例如
begin
test();
end;
/
select 1 from dual;
--call test();不用/来分隔
call test();
select 1 from dual;
- shell 异常捕获,&&和||的使用,$?和1>&2的使用,https://blog.csdn.net/womeng2009/article/details/80814284
- shell中>,>>的使用,https://blog.csdn.net/nahanai/article/details/83861449
- shell变量
# 变量赋值 ##等号两边不能有空格
a=1
a=\'1\'
a="1"
b="213${a}"
# 执行变量 ##某些系统不适用的命令,不能执行
cmd01="sqlldr userid=fb/fb@orcl control=\'C:\Users\Administrator\Desktop\jiefangdai_callout\sqlldr\control.ctl\' log=\'C:\Users\Administrator\Desktop\jiefangdai_callout\sqlldr\test.log\'"
eval cmd01
- $()与${}的使用:https://blog.csdn.net/SeaSky_Steven/article/details/103281133
- 将执行结果存入变量:https://blog.csdn.net/baidu_35757025/article/details/64440047?locationNum=8&fps=1
- 将执行错误存入变量:https://blog.csdn.net/u011575671/article/details/78592162/
- sqlplus -s: 用于输出变量时不会报错
- shell 的判断
if的基本语法:
if [ command ];then
符合该条件执行的语句
elif [ command ];then
符合该条件执行的语句
else
符合该条件执行的语句
fi
12.“” 和‘’的区别,‘’是纯字符,“”可以引用变量
- 一直sqlplus 插入error变量不能成功,是因为error中有中文,sqlplus不能识别
- 判断字符相等
result="load succee"
if [ "$result" == "load succeed" ]; then #加入""
echo 1
else
echo 2
fi