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