ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Insert Statement.
Date Mon, 14 Jul 2008 19:58:35 GMT
I don't know oracle, but in DB2 it's like this:

insert into foo (createdOn) values (CURRENT DATE)

As for returning the value in the bean, no.  But if this is needed, why not
set the current date in Java before calling the insert?

Jeff Butler



On Mon, Jul 14, 2008 at 2:51 PM, kiran vuppla <kirankumar_vuppla@yahoo.com>
wrote:

>   Can I get some example how to use curr date (keyword) inside insert
> statement. Can we able to return/store the same value to Java Bean object as
> I want to store in to my java bean?
>
>
>
> Thanks
> KV
>
> --- On *Mon, 7/14/08, Jeff Butler <jeffgbutler@gmail.com>* wrote:
>
> From: Jeff Butler <jeffgbutler@gmail.com>
> Subject: Re: Insert Statement.
> To: user-java@ibatis.apache.org, kirankumar_vuppla@yahoo.com
> Date: Monday, July 14, 2008, 2:47 PM
>
>
>  Ahh - the truth comes out!
>
> Only one <selectKey> is allowed.  Genrally, the current date is a special
> keyword you can use in an insert statement so you shouldn't need a select
> key just for that.
>
> Jeff Butler
>
>
>
> On Mon, Jul 14, 2008 at 2:33 PM, kiran vuppla <kirankumar_vuppla@yahoo.com>
> wrote:
>
>>   Actually I am using *two* <selectKey> statements inside <insert>
>> statement. But I see only one <selectKey> is working all the time. When I
>> comment any *one*, the *other* is returning the result. *Can we not use
>> two <selectKey> tags inside a <insert>?*
>>
>>
>>
>> <insert id="insertSession" parameterClass="Session">
>>   *<selectKey resultClass="int" keyProperty="id">
>>     select SESSIONID_SEQUENCE.NEXTVAL as id from dual
>>   </selectKey>
>>   <selectKey resultClass="java.sql.Date" keyProperty="createdOn">
>>     select sysdate as createdOn from DUAL
>>   </selectKey>*
>>   insert into ppsession (SESSIONID, NAME, DESCRIPTION, CREATEDON,
>> CREATEDBY, SESSIONSTATE) VALUES
>>   (#id#, #name#, #description#, #createdOn#, #createdBy#, #state#)
>>  </insert>
>>
>>
>>
>> Thanks,
>> KV
>>
>> --- On *Mon, 7/14/08, Larry Meadors <larry.meadors@gmail.com>* wrote:
>>
>> From: Larry Meadors <larry.meadors@gmail.com>
>> Subject: Re: Insert Statement.
>> To: user-java@ibatis.apache.org, kirankumar_vuppla@yahoo.com
>> Date: Monday, July 14, 2008, 8:54 AM
>>
>>  Are you calling insert() or update()?
>>
>> Larry
>>
>> On Mon, Jul 14, 2008 at 7:27 AM, kiran vuppla
>> <kirankumar_vuppla@yahoo.com> wrote:
>> > Hi,
>> >
>> >   I am having a insert statement and in which I am trying to insert values
>> > that I recieve from <selectKey> result. But I see that it is not
>> inserting
>> > the value. Please let me know if it is correct way to do it?
>> >
>> >
>> >
>> > In the below It is inserting null values for "#date#" which I
>> get from
>> > <selectKey> statement.
>> >
>> >
>> >
>> > <insert id="insertValues"
>> parameterClass="Session">
>> >
>> > <selectKey resultClass="java.sql.Date" type="pre"
>> keyProperty="date">
>> >
>> >   select sysdate from dual
>> >
>> > </selectKey>
>> >
>> >  insert into SessionTbl (name, date, address, city, zip) values (#name#,
>> > #date#, #address#, #city#, #zip#)
>> >
>> > </insert>
>> >
>> >
>> >
>> > Thanks
>> >
>> > KV
>> >
>>
>>
>>
>
>

Mime
View raw message