use strict; use warnings; use DBI; my $dbname = 'testdb'; # The testdb database must exist my $server = 'localhost'; my $user = 'username'; my $pass = 'password'; my $dbh = DBI->connect( "DBI:InterBase:" . "dbname=" . $dbname . ";host=" . $server . ";ib_dialect=3", $user, $pass, { AutoCommit => 1, RaiseError => 1, FetchHashKeyName => 'NAME_lc' } ); my $sql1 = qq{ CREATE TABLE testtable ( cant DECIMAL(9,3) NOT NULL, vat DECIMAL(4,2) NOT NULL, price NUMERIC(11,5) NOT NULL) }; my $rv = $dbh->do( $sql1 ); my $sql2 = qq{ CREATE VIEW v_testtable ( cant , vat , price , val , vat_val ) AS SELECT tt.cant , tt.vat , tt.price , tt.cant * tt.price , tt.cant * tt.price * tt.vat /100 FROM testtable tt; }; $rv = $dbh->do( $sql2 ); # Insert some data my $sql3 = qq{ INSERT INTO testtable (cant, vat, price) VALUES (?, ?, ?); }; my $st = $dbh->prepare($sql3); my @testval = ( [ 1, 19, 100 ], [ 1, 19, 1000 ], [ 1, 19, 10000 ], [ 1, 19, 100000 ], ); foreach my $val ( @testval ) { $st->execute( @{$val} ); } $dbh->disconnect();