db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonas Pettersson <jlpetters...@gmail.com>
Subject Re: How to SELECT data from in-memory Derby database table?
Date Fri, 11 Nov 2011 14:11:05 GMT
Thanks! That was very helpful.

with ON COMMIT PRESERVE ROWS it works fine.

/Jonas

2011/11/11 Rick Hillegas <rick.hillegas@oracle.com>:
> On 11/11/11 4:39 AM, Jonas Pettersson wrote:
>>
>> DECLARE GLOBAL TEMPORARY TABLE SESSION.memtable (id int, name
>> varchar(10)) NOT LOGGED
>>
> Hi Jonas,
>
> It's likely that you are running with autocommit turned on (this is the
> default). Your temporary table was declared in a way which causes it to
> throw away all of its rows at commit. You can preserve rows over commit by
> adding another clause to the DECLARE GLOBAL TEMPORARY TABLE statement. The
> following example may  help:
>
> ij> connect 'jdbc:derby:memory:db;create=true';
> ij> declare global temporary table session.t_default (id int) not logged;
> 0 rows inserted/updated/deleted
> ij> declare global temporary table session.t_preserve (id int) on commit
> preserve rows not logged;
> 0 rows inserted/updated/deleted
> ij> insert into session.t_default( id ) values ( 1 );
> 1 row inserted/updated/deleted
> ij> insert into session.t_preserve( id ) values ( 1 );
> 1 row inserted/updated/deleted
> ij> select * from session.t_default;
> ID
> -----------
>
> 0 rows selected
> ij> select * from session.t_preserve;
> ID
> -----------
> 1
>
> 1 row selected
>
> Hope that's useful,
> -Rick
>

Mime
View raw message