[OCP 11 Complete Study Guide] [OCP 11 Programmer I Book] [OCP 11 Programmer II Book] [OCP 11 Practice Tests Book] [OCA 8 Book] [OCP 8 Book] [OCP 8 Practice Tests Book] [Blog]
Scott Selikoff wrote:Please do not create 3 threads with identical messages.
S.D. MADHAN
Not many get the right opportunity !
Madhan Sundararajan Devaki wrote:I believe, ? symbol is wildcard symbol in SELECT statement, hence, you may need to somehow escape it within the query.
S.D. MADHAN
Not many get the right opportunity !
Madhan Sundararajan Devaki wrote:When I said "escape" I meant, you need to put some character such as "\" or something that will allow the wild-card to be treated as java place-holder. I hope, you understand what is being conveyed.
karthik swamy wrote:
Madhan Sundararajan Devaki wrote:I believe, ? symbol is wildcard symbol in SELECT statement, hence, you may need to somehow escape it within the query.
Can't we use ? symbol in like keyword because it is giving me this error in that place only.
Sudheer Bhat wrote:
karthik swamy wrote:
Madhan Sundararajan Devaki wrote:I believe, ? symbol is wildcard symbol in SELECT statement, hence, you may need to somehow escape it within the query.
Can't we use ? symbol in like keyword because it is giving me this error in that place only.
Why don't you append % to procId string and have your SQL string as LIKE ?
S.D. MADHAN
Not many get the right opportunity !
Madhan Sundararajan Devaki wrote:You may re-write your query as follows,
String query="SELECT PROCESS_ID,NAME FROM SYS_FILEINFO WHERE to_date(CREATION_DATE) BETWEEN TO_DATE(?,'DD-MM-YYYY') AND TO_DATE(?,'DD-MM-YYYY') AND PROCESS_ID LIKE 'MIP.%'";
(OR like the following)
String PREFIX = "MIP."; // You can use some function to find out the prefix and substitute here.
String query="SELECT PROCESS_ID,NAME FROM SYS_FILEINFO WHERE to_date(CREATION_DATE) BETWEEN TO_DATE(?,'DD-MM-YYYY') AND TO_DATE(?,'DD-MM-YYYY') AND PROCESS_ID LIKE '" + PREFIX + "%'";
S.D. MADHAN
Not many get the right opportunity !
Madhan Sundararajan Devaki wrote:The re-written queries can be used in a prepared statement.
In the first case, you can use the query as it is.
In the second case, just ensure that you populate the value of PREFIX, before calling the con.prepareStatement API.
S.D. MADHAN
Not many get the right opportunity !
Madhan Sundararajan Devaki wrote:Please re-write as follows,
String query="SELECT PROCESS_ID,NAME FROM SYS_FILEINFO WHERE to_date(CREATION_DATE) BETWEEN TO_DATE(?,'DD-MM-YYYY') AND TO_DATE(?,'DD-MM-YYYY') AND PROCESS_ID LIKE " + strProcID;
Also, you need not set the third argument in the pstmt object.
S.D. MADHAN
Not many get the right opportunity !
Madhan Sundararajan Devaki wrote:The re-written query does not affect the creation/execution of PreparedStatement! What do you think will happen if you use the re-written query?
Sudheer Bhat wrote:
karthik swamy wrote:
Madhan Sundararajan Devaki wrote:I believe, ? symbol is wildcard symbol in SELECT statement, hence, you may need to somehow escape it within the query.
Can't we use ? symbol in like keyword because it is giving me this error in that place only.
Why don't you append % to procId string and have your SQL string as LIKE ?