首页-玉祥公司客服

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 部件 流程 SQL
查看: 1594|回复: 1
打印 上一主题 下一主题

[分享] ORA-01846错误解决办法

[复制链接]

542

主题

5916

帖子

1万

积分

作者

Rank: 7Rank: 7Rank: 7

积分
13589
跳转到指定楼层
楼主
发表于 2020-5-12 16:57:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
select order#,orderdate,next_day(orderdate,'MONDAY') "Should Shipdate"
from orders
where order# = 1010;
执行上面的语句发现错误。

ORA-01846: 周中的日无效
是oracle中关于时间拼写的参数(nls_date_language)设置有问题,改成下面的格式就没有错了,用数值1~7分别表示星期天道星期六。一周的第一天是从周天开始的。
SQL> select order#,orderdate,next_day(orderdate,2) "Should Shipdate"
  2  from orders
  3  where order# = 1010;

ORDER# ORDERDATE   Should Shipdate
------ ----------- ---------------
  1010 2009/4/3    2009/4/6
也可以修改参数然后在执行语句
SQL> alter session set nls_date_language='american';
Session altered

SQL> select order#,orderdate,next_day(orderdate,'MONDAY') "Should Shipdate"
  2  from orders
  3  where order# = 1010;

ORDER# ORDERDATE   Should Shipdate
------ ----------- ---------------
  1010 2009/4/3    2009/4/6
参考:
NLS_DATE_LANGUAGE specifies the language to use for the spelling of day and month
names and date abbreviations (a.m., p.m., AD, BC) returned by the TO_DATE and TO_CHAR
functions
NLS_LANGUAGE specifies the default language of the database. This language is used
for messages, day and month names, symbols for AD, BC, a.m., and p.m., and the default
sorting mechanism. This parameter also determines the default values of the parameters
NLS_DATE_LANGUAGE and NLS_SORT.


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

542

主题

5916

帖子

1万

积分

作者

Rank: 7Rank: 7Rank: 7

积分
13589
沙发
 楼主| 发表于 2020-5-12 16:57:55 | 只看该作者
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

手机版|小黑屋|首页-玉祥公司客服  本站关键词:玉祥平台客服

GMT+8, 2024-6-26 16:51 , Processed in 0.120393 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表