Simple Oracle query: literal does not match format string

前端 未结 4 1360
清酒与你
清酒与你 2020-12-21 13:18

I want to execute a simple function in Oracle. The signature is defined as follows:

CREATE OR REPLACE FUNCTION NewCaseListForValidation
(
                            


        
相关标签:
4条回答
  • 2020-12-21 13:55

    It's best not to rely on particular value in NLS_PARAMETERS settings, cause this will make your function break in the env with another NLS_DATE_FORMAT.

    I'd explicitly specify date formatting in your function as suggested in the answer above

    exec :rc := newcaselistforvalidation(to_date('2010-01-01','YYYY-MM-DD'),to_date('2011-01-01','YYYY-MM-DD'),100);
    
    0 讨论(0)
  • 2020-12-21 14:08

    An alternative to the to_date() function is to use the ANSI standard format for DATE or TIMESTAMP literals:

    DATE '2010-01-31'
    TIMESTAMP '2010-01-31 21:22:23'

    Date and time is always specified using ISO rules (YYYY-MM-DD and 24hour format for time)

    This also works on a lot of other (standard compliant) DBMS.

    0 讨论(0)
  • 2020-12-21 14:09

    Query NLS_PARAMETERS in Oracle- you will then be able to see what format your DB is accepting dates in.

    Typically however i use the to_date() function:

    to_date('01-01-2011','DD-MM-YYYY');
    

    In the UK to input my dates.

    0 讨论(0)
  • 2020-12-21 14:15

    INSERT INTO tblDate (dateStart) Values ('20-JUN-2013'); If you change month integer into a string 'DD-MON-YYYY' works as a valid data string without having to preface it with the DATE identifier.

    0 讨论(0)
提交回复
热议问题