Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

sqlplus - Simple Oracle query: literal does not match format string

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

CREATE OR REPLACE FUNCTION NewCaseListForValidation
(
                             p_fromDate in DATE,
                             p_toDate in DATE,
                             p_rowCount in INT
)
RETURN
                             SYS_REFCURSOR
IS
                             return_value SYS_REFCURSOR;
...

I should be able to execute it with:

var rc refcursor
exec :rc := newcaselistforvalidation('2010-01-01','2011-01-01',100);
print :rc

But when typing "newcaselistforvalidation('2010-01-01','2011-01-01',100)", I get:

ERROR at line 1:
ORA-01861: literal does not match format string
ORA-06512: at line 1

I googled a bit and it seems I can't figure out to type the date in a correct format. Can anyone help me?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...