我有一个简单的查询字符串。我在querystring中使用datetime时出现奇怪的数据库错误,无法弄清原因。查询在oracle上运行时没有错误。
Dim selectedDate As String = (Today.AddDays(-2000)).ToString("d-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US")).ToUpper()
Dim cmd As New OracleCommand
cmd.Connection = xConnection
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT * FROM ORDER_DETAIL WHERE ORDER_TYPE='PO' AND STATUS<>'CANCEL' AND PN='XXXXXX' AND LAST_DATE_RECEIVED>TO_DATE('27-JUN-2013','DD/mm/YYYY')"
Dim dr1 As OracleDataReader = cmd.ExecuteReader()
我认为它与Oracle服务器或提供程序无关,因为如果删除日期部分,它不会给出错误。你有什么主意吗?
以下异常详细信息:
Oracle.ManagedDataAccess.Client.OracleException
HResult=0x80004005
Message=ORA-03111: Break received on communication channel
Source=Oracle Data Provider for .NET, Managed Driver
StackTrace:
at OracleInternal.TTC.TTCExecuteSql.ReceiveExecuteResponse(Accessor[]& defineAccessors, Accessor[] bindAccessors, Boolean bHasReturningParams, SQLMetaData& sqlMetaData, SqlStatementType statementType, Int64 noOfRowsFetchedLastTime, Int32 noOfRowsToFetch, Int32& noOfRowsFetched, Int64& queryId, Int32 longFetchSize, Int64 initialLOBFetchSize, Int64[] scnFromExecution, Boolean bAllInputBinds, Int32 arrayBindCount, DataUnmarshaller& dataUnmarshaller, MarshalBindParameterValueHelper& marshalBindParamsHelper, Int64[]& rowsAffectedByArrayBind, Boolean bDefineDone, Boolean& bMoreThanOneRowAffectedByDmlWithRetClause, List`1& implicitRSList, Boolean bLOBArrayFetchRequired)
at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteReader(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, OracleDataReaderImpl& rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, Int64& internalInitialLOBFS, OracleException& exceptionForArrayBindDML, OracleConnection connection, OracleLogicalTransaction& oracleLogicalTransaction, IEnumerable`1 adrianParsedStmt, Boolean isDescribeOnly, Boolean isFromEF)
at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader()
at VB_TestApp.Module1.Main() in c:\users\.....
Inner Exception 1:
NetworkException: ORA-03111: Break received on communication channel
答案 0 :(得分:2)
以下语法需要稍作更改。问题中的语法具有日期格式语法错误。
cmd.CommandText = "SELECT * FROM ORDER_DETAIL WHERE ORDER_TYPE='PO' AND STATUS<>'CANCEL' AND PN='XXXXXX' AND LAST_DATE_RECEIVED>TO_DATE('27-JUN-2013','DD/mm/YYYY')"
可以更改为标准语法
AND LAST_DATE_RECEIVED> date '2013-06-27'"
Oracle支持ANSI日期格式-Standard Docs Link