Oracle 日期和 NLS 设置
我收到 ORA-01858 异常。我认为这是由于 NLS 设置和日期造成的:
declare
currentDate DATE := sysdate;
queryString VARCHAR2(300) := '... where blablabla = :bind_timestamp ...';
sql_cursor integer;
begin
sql_cursor := dbms_sql.open_cursor;
dbms_sql.parse(sql_cursor, queryString, dbms_sql.native);
dbms_sql.bind_variable(sql_cursor, ':bind_timestamp', currentDate);
rowsProcessed := dbms_sql.execute(sql_cursor);
dbms_sql.close_cursor(sql_cursor);
end;
dbms_sql.bind_variable(sql_cursor, ':bind_timestamp', currentDate);
是否依赖于 NLS?
我的意思是,某些 NLS 设置可以正常工作,而其他设置则失败?
I get an ORA-01858 exception. I think it is due to NLS settings and date:
declare
currentDate DATE := sysdate;
queryString VARCHAR2(300) := '... where blablabla = :bind_timestamp ...';
sql_cursor integer;
begin
sql_cursor := dbms_sql.open_cursor;
dbms_sql.parse(sql_cursor, queryString, dbms_sql.native);
dbms_sql.bind_variable(sql_cursor, ':bind_timestamp', currentDate);
rowsProcessed := dbms_sql.execute(sql_cursor);
dbms_sql.close_cursor(sql_cursor);
end;
Is dbms_sql.bind_variable(sql_cursor, ':bind_timestamp', currentDate);
NLS dependent?
I mean with some NLS settings it works normally and others it fails?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理日期时,如果您提供自己的格式字符串,则 NLS 设置不相关:
我的猜测是您依赖于自动类型杂耍,即,您提供一个字符串并让 Oracle 根据需要将其转换为日期:
在这种情况下,Oracle 使用 NLS 设置中指定的默认格式。
更新:顺便说一句,ORA-01858代码意味着:
When dealing with dates, NLS settings are not relevant if you provide your own format string:
My guess is that you are relying on automatic type juggling, i.e., you are providing a string and letting Oracle cast it to date as required:
In that case, Oracle uses the default format as specified in your NLS settings.
Update: BTW, the ORA-01858 code means: