您的位置:首页 > 其它

简单的存储过程示例

2015-10-20 14:10 253 查看
declare
cusCode varchar2(255);
cusId number(19);
bindStatus varchar2(255);
begin
For cus in (select *
from gt_ali_order t
where (t.status_type = 'WAITACCEPT' or
t.status_type = 'ACCEPT')
and t.gmt_commit >
to_date('20150707 000000', 'yyyyMMdd hh24miss')
and t.gmt_commit < to_date('20150715 000000', 'yyyyMMdd hh24miss')) loop
select gt_sys_customer_seq.nextval into cusCode from dual;
while (length(cusCode) < 7) loop
begin
cusCode := '0' || cusCode;
end;
end loop;
select gt_sys_customer_seq.nextval into cusId from dual;
dbms_output.put_line(cusCode || '---' || cusId);
if(cus.status_type='ACCEPT') then
bindStatus:='BIND';
else
bindStatus:='NEW_ADDRESS';
end if;
insert into gt_sys_customer
(ID,
CREATED_TIME,
CREATOR_ID,
LOCK_VERSION,
CUS_CODE,
CUS_NAME,
CUS_FULL_NAME,
CUS_LINKMAN,
CUS_PHONE1,
CUS_ADDRESS,
STATUS,
OUT_CODE,
ORIGIN,
BINDING_STATUS,
cus_Owner_Site_Code,
cus_Owner_Site_Name,
CUS_OWNER_SITE_ID,
re_mark
)
values
(cusId,
sysdate,
1,
0,
'V' || cusCode,
cus.send_person,
cus.send_company,
cus.send_person,
cus.send_phone,
cus.send_address,
'ENABLE',
'A' || cusCode,
'ALIBABA',
bindStatus,
cus.send_site_code,
cus.send_site_name,
cus.send_site_id,
'sqlInsert'
);
insert into gt_table_sync
(id, table_name, cur_version, operate,re_mark)
values
(cusId, 'SysCustomer', gt_table_sync_seq.nextval, 'INSERT','sqlInsert');
update gt_ali_order t
set t.customer_id = cusId,
t.customer_code = 'V' || cusCode,
t.customer_name = t.send_person
where t.logistic_id = cus.logistic_id;
end loop;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: