日期格式错误
declare
v_date date;
CURSOR abc
is
select a_date
from abc
where part_id ='E00000001';
begin
open abc;
fetch abc into v_date;
close abc;
dbms_output.put_line('date is '||v_date);
end;
/
这里我获取的日期是“31/12/2099 23:59:59”,现在的问题是,当我使用游标将其获取到 v_date 时,它即将到来......日期是 31/DEC/99
<块引用>可能是什么问题
我使用 oracle 作为 RDBMS
declare
v_date date;
CURSOR abc
is
select a_date
from abc
where part_id ='E00000001';
begin
open abc;
fetch abc into v_date;
close abc;
dbms_output.put_line('date is '||v_date);
end;
/
Here my date that is been fetched is '31/12/2099 23:59:59',Now the issue is that when i fetch this into v_date using cursor its coming ....date is 31/DEC/99
What may be the issue
I am using oracle as RDBMS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到你的代码让我困扰的一件事 -
abc
是表和光标的名称......恕我直言,这是不好的做法。至于日期格式问题,请尝试
您看到的输出很可能是有关将
DATE
转换为VARCHAR2< 时使用的日期格式的某些 db/session-level NLS 设置的结果/代码> .我的代码使用显式日期格式来独立于该设置工作(这并不理想,因为它可能会在需要本地化/全球化的情况下产生问题!)。
I see one thing that bothers me with your code -
abc
is the name of the table and of the cursor... that's bad practice IMHO.As for the date format problem try
The output you see is most probably the result of some db/session-level NLS setting regarding the date format which is used when converting a
DATE
to aVARCHAR2
. My code uses an explicit date format to work independently of that setting (which is NOT ideal since it might make it problematic in situations where localization/globalization is needed!).