ecrdesc

Well I played around with this a little more and came up with a Perl script that will dump ECR descriptions fairly easy. From what I understand that's mostly what we want access to from a Linux box (though I could envision wanting other things perhaps in the future). The problem as I see it is that this script will only run on lynx12. It should be runnable from any machine really however you would need to install the DBD module for Informix for Perl access. Unfortunately this requires at least an Informix Client SDK and that's not free! :-(

Here's the simple script (currently at lynx12:/tmp/ecrdesc.pl):

#!/usr/bin/perl
################################################################################
#
# File:         ecrdesc
# Description:  This script will dump out the description for the ECR #(s)
#               passed in.
# Author:       Andrew@DeFaria.com
# Created:      Fri Jan  7 15:35:13 PST 2005
# Language:     Perl
#
# (c) Copyright 2005, LynxWorks Inc., all rights reserved
#
################################################################################
use strict;
use warnings;
use DBI;

my $DB;

# Called when a database error has occurred
sub DBError {
  my $msg       = shift;
  my $statement = shift;

  print $msg . "\nError #" . $DB->err . " " . $DB->errstr . "\n";

  if (defined $statement) {
    print "SQL Statement: $statement\n";
  } # if

  exit $DB->err;
} # DBError

# Connect to database. Note this is using anonymous access (read only)
$DB = DBI->connect("DBI:Informix:lynxmigr1")
  or DBError "Unable to open database";

# Loop through ECR #s from the command line
foreach my $ecr (@ARGV) {
  print "ECR #: $ecr\n";

  my $statement    = "select description from defect where pkey=\"$ecr\"";
  my $sth    = $DB->prepare ($statement)
    or DBError "Unable to prepare statement", $statement;

  $sth->execute ()
    or DBError "Unable to execute statement", $statement;

  # Defect records are unique per pkey (AKA ECR) there for there will
  # only be one entry in @row. Also the description is returned as one
  # large string.
  my @row = $sth->fetchrow_array;

  if (!@row) {
    # @row is empty if there was no ECR by that number
    print "Nothing found!\n";
  } else {
    my $desc = pop @row;
    print "Description:\n" . "-" x 80 . "\n" . $desc . "\n" . "-" x 80 . "\n";
  } # if
} # foreach

$DB->disconnect;

exit;