how to update /select date field using mybatis xml mapper with oracle db

354 views
Skip to first unread message

Vikas Khamkar

unread,
Aug 26, 2021, 3:13:01 AM8/26/21
to mybatis-user
HI Everyone,

I need help. i want to update /select data in table based on date field using mybatis xml mapper. plz let me know the ways through which we can do this?

Thanks And Regards,
Vikas Khamkar

Guy Rouillier

unread,
Aug 26, 2021, 4:31:00 AM8/26/21
to mybatis-user
I'm not clear on what you are trying to accomplish.  Are you wanting to "select for update" followed by "update where current of cursor"?  My opinion is that you are better off just doing an update with a WHERE clause using the date field.  The first approach creates locks that can potentially last for an extended period.

--
Guy Rouillier
--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/d58486a2-cfe1-40e7-9809-66298ec0179dn%40googlegroups.com.

Vikas Khamkar

unread,
Aug 26, 2021, 5:27:44 AM8/26/21
to mybatis-user
Hi Guy,

I want to select data based on date criteria  from oracle database.

Vikas Khamkar

unread,
Aug 26, 2021, 5:44:03 AM8/26/21
to mybatis-user
Below is my select statement in xml file where as data type of column createdon is date in oracle db.  #{dt} is the date value passing through application. But below select doesn't give me output back if i add createdon filed in query

<select id="getBatchDtls" resultType="io.billdesk.fileuploaddownload.payload.BatchResponse">

        select b.inputValue,f.fileName
        from aaa a, bbb b, ccc c, ddd d ,eee e, fff f
        where a.inputId=b.inputId
        and a.Id=c.Id
        and a.meCode=d.meCode
        and a.inputid= f.inputid(+)
        and f.batchid(+)=e.batchid
        and a.Id=#{bCode}
        and a.code=#{mCode}
        <if test="dt != null">
            and createdon like #{dt}
        </if>
    </select>


Guy Rouillier

unread,
Aug 26, 2021, 6:51:50 AM8/26/21
to mybatis-user
The LIKE operator in SQL is for string pattern matching.  


Here is a discussion of using the LIKE operator with date fields.  Basically, date fields are not directly compatible with the LIKE operator.  You can extract the contents of the date field into a string, and then use that for comparison with the LIKE operator.  However, I'm suspecting that you are attempting to do some sort of comparison with the date field, and you would be better off rephrasing your SQL to use appropriate date functions.


--
Guy Rouillier

Vikas Khamkar

unread,
Aug 31, 2021, 12:40:41 AM8/31/21
to mybatis-user
Thanks Guy for help!!!
Reply all
Reply to author
Forward
0 new messages