建表:
--建立订单表
create table orderf(
orderno number,--订单号
oname varchar2(20),--客户名
price number(7,2),--总价
deadline date,--预定日期
delivery date,--交付日期
clauseNo varchar2(20),--条款号
product varchar2(20)--产品名
);
--插入数据
insert into orderf values(612,'BLAKE',5860,to_date('10-1月','dd-mon'),to_date('11-1月','dd-mon'),'1.2.3','IPHONE');
insert into orderf values(610,'BOB',101.4,to_date('10-1月','dd-mon'),to_date('20-1月','dd-mon'),'2.3','SHOSE');
insert into orderf values(601,'CLARK',60.8,to_date('01-5月','dd-mon'),to_date('30-5月','dd-mon'),'1.3','CUP');
insert into orderf values(600,'ANNE',42,to_date('12-3月','dd-mon'),to_date('19-2月','dd-mon'),'1','ACE TENNIS RACKET II');
insert into orderf values(600,'LISA',58,to_date('17-3月','dd-mon'),to_date('29-3月','dd-mon'),'2','ACR TENNIS NET');
insert into orderf values(600,'PETER',24.6,to_date('01-5月','dd-mon'),to_date('29-5月','dd-mon'),'1.5.3','PEN');
insert into orderf values(612,'BLAKE',1.5,to_date('12-1月','dd-mon'),to_date('15-1月','dd-mon'),'1.2.4','CARD');
insert into orderf values(610,'BOB',2.0,to_date('16-1月','dd-mon'),to_date('19-1月','dd-mon'),'2.4','BREAD');
insert into orderf values(601,'CLARK',6.8,to_date('01-5月','dd-mon'),to_date('10-5月','dd-mon'),'1.4','NOEBOOK');
select * from orderf;
表:
题目:
我的代码:
declare
cursor test2 is select orderno,deadline,delivery from orderf where (delivery-deadline)>15;
o_no orderf.orderno%type;
o_deadline orderf.deadline%type;
o_delivery orderf.delivery%type;
begin
for orderf in test2 loop
o_no:=orderf.orderno;
o_deadline:=orderf.deadline;
o_delivery:=orderf.deadline+15;
update orderf set delivery=o_delivery where orderno=o_no;
dbms_output.put_line('订单号:'||o_no||',预定日期:'||o_deadline||',交付日期:'||o_delivery);
end loop;
end;
运行结果:
问题:为什么日期的显示在建表和填充数据后还是yy/mm/dd格式,使用游标运行代码后,像上图那样,后面还跟 -21