I have the following view in Oracle
SELECT
1 as col1
,2 as col2
,CASE
WHEN salesdata.date1 > '01/01/0001'
THEN 24*60*(salesdata.date1 - salesdata.date2)
ELSE NULL
END AS dateresult
FROM
salesdata
I'm retrieving this view with a simple SELECT:
select * from viewsample
Then I run this line below:
OracleConnection connection = new OracleConnection(connectionString);
connection.Open();
DbCommand command = connection.CreateCommand();
command.CommandTimeout = 14400;
command.CommandText = sql;
DbDataReader reader = command.ExecuteReader(CommandBehavior.SingleRow);
When ASP.Net runs this line I get the error "ORA-01843: not a valid month".
It seems that the command understands the "dateresult" column as a DATE, but it is a INTEGER.
I've already tried a CAST like this and didn't work either:
CAST(24*60*(salesdata.date1 - salesdata.date2) as INTEGER)
You'll have to explicitly provide the date format of the string
to_date('01/01/0001','DD/MM/YYYY')
in the select. If not provided it uses the default setting on the client to do the implicit conversion to a date. The default date format is dependent on the regional settings of the client machine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.