문제

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?

도움이 되었습니까?

해결책

When dealing with dates, NLS settings are not relevant if you provide your own format string:

WHERE arrival=TO_DATE('2011-09-05', 'yyyy-mm-dd')

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:

WHERE arrival='05/09/2011'

In that case, Oracle uses the default format as specified in your NLS settings.

Update: BTW, the ORA-01858 code means:

a non-numeric character found where a digit was expected

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top