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