Listing 1: Create the tables
#!/usr/bin/perl
;# make_wo_db.pl
;# Create the work order database tables.
;# For simplicity, the connection string is hard-coded.
;# This also assumes the database has been created, and
;# the user 'user' added with a default tablespace assigned.
use DBI;
$dbh = DBI->connect('dbi:Oracle:wodb', 'user', 'password')
or print "Unable to connect to database: $DBI::errstr\n";
$dbh->do(q{
CREATE TABLE Person
(id number(8), -- generated internally
first_name varchar(20),
last_name varchar(20),
dept varchar(40),
phone varchar(15))
}) or die "PERSON creation error: $DBI::errstr\n";
$dbh->do(q{
CREATE TABLE System
(id number(8), -- generated internally
name varchar(40),
contact_id number(8)) -- from Person table
}) or die "SYSTEM creation error: $DBI::errstr\n";
$dbh->do(q{
CREATE TABLE Work_order
(id number(8),
requester_id number(8), -- from Person table
system_id number(8), -- from System table
assigned_id number(8), -- technician assigned,
-- from Person table
date_opened date,
date_started date,
date_closed date,
description varchar(256),
total_hours number(6,2))
}) or die "WORK_ORDER creation error: $DBI::errstr\n";
|