最近工作需要 ,要对一张表的char类型作为 查询条件 ,进行数据加工 ,每日装入目标表 。
思路很简单 : 做一个存储,日增模式把数据装入目标表 。
思路没错,但是测试的时候 无论如何目标表都没有数据 。但是 ,手工把参数作为常量带入又有数据 ,很奇怪。
表结构 test( id varchar2(12) , create_dt char(19) ) 。
分析,
id | create_dt |
1 | 2022-10-31 |
2 | 2022-10-30 |
存储过程 ,pro_test( acctdt in varchar2 )
select * from test where create_dt='2022-10-31' ; 语句能查询到数据 。
此时传入参数 pro_test('2022-10-31') ,如果存储过程
select * from test where create_dt = acctdt ; 预测应该能查到数据 ,实际无法查到数据 。
此时要想查到数据 ,采用如下方式
select * from test where substr(create_dt,1,10) = acctdt ;