Hi,
This is a bug. Referential integrity for in-memory databases doesn't
work in some cases in version 1.1.102. This will be fixed in the next
release.
Regards,
Thomas
On Thu, Oct 30, 2008 at 2:16 PM, Jacek <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> The below snippets shows that the referential constraint with ON
> DELETE RESTRICT does not throw an exception as expected. Instead it
> deletes the record from the master table leaving orphan record from
> the detail table.
>
> conn = DriverManager.getConnection("jdbc:h2:mem:a");
> Statement stmt = conn.createStatement();
>
> stmt.executeUpdate("create table master (id identity)");
> stmt.executeUpdate("create table detail (id identity,
> master_id bigint"
> +", constraint detail_master_fk foreign key (master_id) "
> +"references master (id) on delete restrict)");
>
> stmt.executeUpdate("insert into master values (0)");
> stmt.executeUpdate("insert into detail values (0,0)");
> stmt.executeUpdate("delete from master");
>
> ResultSet rs = stmt.executeQuery("select count(*) from
> master"); rs.next();
> System.out.println("master count: "+rs.getString(1));
>
> rs = stmt.executeQuery("select count(*) from detail");
> rs.next();
> System.out.println("detail count: "+rs.getString(1));
>
> rs.close();
> stmt.close();
> conn.close();
>
> Am I doing something wrong or is it a bug? (I'm using latest release)
>
> Regards,
> Jacek
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---