3 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/};
5 plan skip_all, 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test. ' .
6 'Warning: This test drops and creates a table called \'artist\''
7 unless ($dsn && $user && $pass);
11 DBICTest->class("Schema")->compose_connection('OraTest' => $dsn, $user, $pass);
13 my $dbh = OraTest::Artist->storage->dbh;
16 $dbh->do("DROP SEQUENCE artist_seq");
17 $dbh->do("DROP TABLE artist");
19 $dbh->do("CREATE SEQUENCE artist_seq START WITH 1 MAXVALUE 999999 MINVALUE 0");
20 $dbh->do("CREATE TABLE artist (artistid NUMBER(12), name VARCHAR(255))");
21 $dbh->do("ALTER TABLE artist ADD (CONSTRAINT artist_pk PRIMARY KEY (artistid))");
23 CREATE OR REPLACE TRIGGER artist_insert_trg
24 BEFORE INSERT ON artist
27 IF :new.artistid IS NULL THEN
28 SELECT artist_seq.nextval
35 OraTest::Artist->load_components('PK::Auto::Oracle');
37 # test primary key handling
38 my $new = OraTest::Artist->create({ name => 'foo' });
39 is($new->artistid, 1, "Oracle Auto-PK worked");
43 OraTest::Artist->create({ name => 'Artist ' . $_ });
45 my $it = OraTest::Artist->search( {},
48 order_by => 'artistid' }
50 is( $it->count, 3, "LIMIT count ok" );
51 is( $it->next->name, "Artist 2", "iterator->next ok" );
54 is( $it->next, undef, "next past end of resultset ok" );
57 $dbh->do("DROP SEQUENCE artist_seq");
58 $dbh->do("DROP TABLE artist");