When writing Java, there is a way to query faster than other methods, but in the database query very quickly, originally because of the application of parameterized query when the parameter type error reason
1 Select *2 fromTransactionno,3 Fmis_accountrecord Accountrecord,4 UserInfo Inputuser,5 UserInfo CheckUser,6 transspecialoperation A,7 AccountInfo C8 whereInputuser.id (+)=Transactionno.ninputuserid9 andCheckuser.id (+)=Transactionno.ncheckuseridTen andTransactionno.id (+)=accountrecord.ntransactionnoid One andA.ntransactionnoid=transactionno.id A andAccountrecord.ndirectionid= 2 - andAccountrecord.nofficeid= 1 - andAccountrecord.ncurrencyid= 1 the andA.npayaccountid=C.id (+) - andAccountrecord.dtexecutebetween ? and? + andNVL (Accountrecord.nstatusid,0)>= 0 A andTransactionno.ntransactiontypeid= 559
After the modification the program quickly:
// ps.settimestamp (1, tsdatestart); // Ps.settimestamp (2, tsdateend); New java.sql.Date (Tsdatestart.gettime ())); Ps.setdate (new java.sql.Date (Tsdateend.gettime ()));
Refer to C #:
The code is as follows
String sql = "SELECT * from Lis_v_labtestsample WHERE patient_id=:P";
Hlsaccess.commandtext = SQL;
HlsAccess.Parameters.Clear ();
HLSACCESS.PARAMETERS.ADD (":P", Oracle.DataAccess.Client.OracleDbType.Varchar2). Value = Patid;
This specifies that the type of the parameter is VARCHAR2, but the database is indeed number, which causes the field type error to result in the table scan, resulting in a slow query.
SQL queries in the database are fast, but queries for slower workarounds in the program