大概思路:1. 用过程取日期 19691006
2. update table_name set field_date = to_date('19691006',yyyymmdd') where ...
2. update table_name set field_date = to_date('19691006',yyyymmdd') where ...
解决方案 »
- PLS-00357在此上下文中不允许表、视图或索引引用SWQ_BBS.NEXTVAL
- 一条修改语句,要修改的字段:[金币] yxb,[经验] Exp [最大回合数] maximumNumberOfRound 如果最大回合数比数据库大就替代
- 两个数据库怎么创建物化视图更新数据
- 菜鸟求助:如何删除一个用户下的所有表?
- 关于数据库的数据文件大小的讨论...
- 请教oracle重装问题,50分,解决立刻给。
- 请教:存储过程要返回的一个参数数据的问题。
- 触发器问题,请教?
- 急急急!!!我的数据库连接不上
- Oracle如何跨服务器实时生成视图
- ORACLE中,如何在一个表中找到某一列最大的两条记录?例如找出两条登记号最大的记录?注:登记号整型且唯一
- 数据统计,涉及日期问题,请教!
15,to_date('19'||substr(sfzhm,7,6),'YYYY-MM-DD')),decode(length(sfzhm),18,substr(sfzhm,length(sfzhm)-1,1),
15,substr(sfzhm,length(sfzhm),1)) from ry_jbxx where a.sfzhm=sfzhm)表名:ry_jbxx 列名:sfzhm为身份证号码 csrq为出生日期
xb为性别
table_name:你的表名称
id:身份证字段名称
birth_day:生日字段
gender:性别
intlen int;
intVal int;
chrBir char(8);
chrMal char(1);
chrID char(18);
begin
chrID := chraa;
intlen = len(trim(chraa));//取得ID字段的长度
if intlen = 15 then //判断ID是多少位
chrBir := substr(chrID,7,6); //取出出生日期(第七位开始的六个数)
chrMal := substr(chrID,-1); //取出性别(最后一位)
else
chrBir := substr(chrID,9,6); //取出出生日期(第九位开始的六个数)
//先取出后两位,在取出后两位中的前一位(倒数第二位)
chrMal := substr(substr(chrID,-2),1,1);
end if; //判断年份以便补齐
intVal := to_number(substr(chrBir,1,2));
if intVal > 4 then //以今年为例,可以修改
chrBir := '19' || chrBir;
else
chrBir := '20' || chrBir;
end if; //判断性别位是否是偶数
if mod(to_number(chrMal),2) = 0 then
chrMal := F;
else
chrMal := M;
end if;
//修改语句
update table_name set Birthday=to_date(chrBir,'YYYYMMDD'),Gender=chrMal where ID=chraa;
commit;//忘了是不是可以提交了
end;
create procedure pro_test as
cursor c is select a.user_id, a.identify from user_info a; --如果表为user_info
i number(10); --身份证号码的位数
v_birthday date; --生日
identify varchar2(20); --号码
begin
open c;
loop
fetch c into i,identify;
exit when c%notfound;
if length(identify)=15 then --15位的身份证在这里处理
v_birthday:=to_date(concat('19',substr('210522741005001',7,6)),'yyyymmdd');
--假设2000年后没有15位的号码
else --18位的在这里处理
v_birthday:=to_date(substr('210522196912060527',7,8),'yyyymmdd');
--2000年前的可能有15位也可能有18位的号码
end if;
update user_info b set b.生日字段=v_birthday where b.user_id=i;
commit;
end loop;
close c;
exception
when others then
rollback;
end;
up一下.