Use Database function, i.e. CURRENT_TIMESTAMP in insert sql

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Use Database function, i.e. CURRENT_TIMESTAMP in insert sql

James Haugen
How do i use the function CURRENT_TIMESTAMP with a stored procedure call? I am getting a bad sql grammar exception from DB2.

<insert id="insertSTUFF">
<![CDATA[{ call ${JDBC.CREATOR}.TABLE_INSERT(
#{data.Nr,mode=IN,jdbcType=DECIMAL},
#{data.TokenNr,mode=IN,jdbcType=DECIMAL},
#{data.EnterTs,mode=IN,jdbcType=TIMESTAMP},
CURRENT_TIMESTAMP

)}
]]>
</insert>

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Tim
Reply | Threaded
Open this post in threaded view
|

Re: Use Database function, i.e. CURRENT_TIMESTAMP in insert sql

Tim
I believe you have to call it as a function (add () to the end)

Sent from my iPhone

On Feb 19, 2019, at 12:59, James Haugen <[hidden email]> wrote:

How do i use the function CURRENT_TIMESTAMP with a stored procedure call? I am getting a bad sql grammar exception from DB2.

<insert id="insertSTUFF">
<![CDATA[{ call ${JDBC.CREATOR}.TABLE_INSERT(
#{data.Nr,mode=IN,jdbcType=DECIMAL},
#{data.TokenNr,mode=IN,jdbcType=DECIMAL},
#{data.EnterTs,mode=IN,jdbcType=TIMESTAMP},
CURRENT_TIMESTAMP

)}
]]>
</insert>

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Use Database function, i.e. CURRENT_TIMESTAMP in insert sql

James Haugen
Nope, that gives me a different sql exception, Invalid input CALL SQL syntax.

On Tuesday, February 19, 2019 at 12:37:06 PM UTC-6, h3adache wrote:
I believe you have to call it as a function (add () to the end)

Sent from my iPhone

On Feb 19, 2019, at 12:59, James Haugen <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="7kW17WCBAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">james....@...> wrote:

How do i use the function CURRENT_TIMESTAMP with a stored procedure call? I am getting a bad sql grammar exception from DB2.

<insert id="insertSTUFF">
<![CDATA[{ call ${JDBC.CREATOR}.TABLE_INSERT(
#{data.Nr,mode=IN,jdbcType=DECIMAL},
#{data.TokenNr,mode=IN,jdbcType=DECIMAL},
#{data.EnterTs,mode=IN,jdbcType=TIMESTAMP},
CURRENT_TIMESTAMP

)}
]]>
</insert>

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="7kW17WCBAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Use Database function, i.e. CURRENT_TIMESTAMP in insert sql

Guy Rouillier-2
In reply to this post by James Haugen
What version of DB2 are you using?  According to the DB2 documentation, CURRENT_TIMESTAMP should work:


Unfortunately, I don't have DB2 installed at the moment.  Are you certain that CURRENT_TIMESTAMP is causing your grammar exception?  Looks like from the following example, DB2 doesn't use the curly braces in a CALL statement.


--
Guy Rouillier

On 2/19/2019 12:59:53 PM, "James Haugen" <[hidden email]> wrote:

How do i use the function CURRENT_TIMESTAMP with a stored procedure call? I am getting a bad sql grammar exception from DB2.

<insert id="insertSTUFF">
<![CDATA[{ call ${JDBC.CREATOR}.TABLE_INSERT(
#{data.Nr,mode=IN,jdbcType=DECIMAL},
#{data.TokenNr,mode=IN,jdbcType=DECIMAL},
#{data.EnterTs,mode=IN,jdbcType=TIMESTAMP},
CURRENT_TIMESTAMP

)}
]]>
</insert>

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.