Removed /usr/local from CDPATH
[clearscm.git] / ecrc / ecrdesc
1 #!/usr/bin/perl
2 ################################################################################
3 #
4 # File:         ecrdesc
5 # Description:  This script will dump out the description for the ECR #(s) 
6 #               passed in.
7 # Author:       Andrew@DeFaria.com
8 # Created:      Fri Jan  7 15:35:13 PST 2005
9 # Language:     Perl
10 #
11 # (c) Copyright 2005, LynxWorks Inc., all rights reserved
12 #
13 ################################################################################
14 use strict;
15 use warnings;
16 use DBI;
17
18 my $DB;
19
20 # Called when a database error has occurred
21 sub DBError {
22   my $msg       = shift;
23   my $statement = shift;
24
25   print $msg . "\nError #" . $DB->err . " " . $DB->errstr . "\n";
26
27   if (defined $statement) {
28     print "SQL Statement: $statement\n";
29   } # if
30
31   exit $DB->err;
32 } # DBError
33
34 # Connect to database. Note this is using anonymous access (read only)
35 $DB = DBI->connect("DBI:Informix:lynxmigr1")
36   or DBError "Unable to open database";
37
38 # Loop through ECR #s from the command line
39 foreach my $ecr (@ARGV) {
40   print "ECR #: $ecr\n";
41
42   my $statement = "select description from defect where pkey=\"$ecr\"";
43   my $sth       = $DB->prepare ($statement)
44     or DBError "Unable to prepare statement", $statement;
45
46   $sth->execute ()
47     or DBError "Unable to execute statement", $statement;
48
49   # Defect records are unique per pkey (AKA ECR) there for there will
50   # only be one entry in @row. Also the description is returned as one
51   # large string.
52   my @row = $sth->fetchrow_array;
53
54   if (!@row) {
55     # @row is empty if there was no ECR by that number
56     print "Nothing found!\n";
57   } else {
58     my $desc = pop @row;
59     print "Description:\n" . "-" x 80 . "\n" . $desc . "\n" . "-" x 80 . "\n";
60   } # if
61 } # foreach
62
63 $DB->disconnect;
64
65 exit;