SQL/Oracle SQL
SQL 실습 : next_day() 요일 오류
구구콘
2021. 2. 4. 02:06
cmd의 sqlplus에서 작성
오류코드 : ORA-01846: not a valid day of the week
SQL> select next_day(sysdate, 'monday') from dual;
ERROR at line 1:
ORA-01846: not a valid day of the week
원인:
next_day의 요일 형식 'monday'가
sqlplus의 nls_date_language에 맞지 않는 형식이기 때문이다.
sqlplus의 nls_date_language 확인방법:
select * from nls_session_parameters;
확인 결과:
NLS_DATE_LANGUAGE
KOREAN
즉, nls_date_language가 korean으로 설정되어 있어,
american 형식의 'monday'를 읽을 수 없던 것.
해결 case1:
SQL> select next_day(sysdate, '월요일') from dual;
해결 case2:
SQL> alter session set nls_date_language = 'american';
SQL> select next_day(sysdate, 'monday') from dual;