#!/usr/local/bin/perl -w # Paper stock preview CGI use strict; use DBI; use DBD::Oracle qw(:ora_types); use CGI; # Set oracle home environment $ENV{ORACLE_HOME}='/home/oracle/OraHome1'; # Connect as Oracle my $dbh=DBI->connect("dbi:Oracle:tnsentry","user","passwd"); # Use CGI my $q = new CGI; my $stock_id = $q->param('stock_id'); # get paper stock id # Find the url and image size from another table my $sth = $dbh->prepare("select stock_url, stock_imagesize from stock where stock_id=?"); $sth->execute($stock_id); my @res=$sth->fetchrow_array(); $sth->finish; if ($res[0] eq 'CLOB') { # stock image is stored directly inside the database $dbh->{LongReadLen}=$res[1]; # set up the CLOB retrieval size my $sth=$dbh->prepare("select stock_mimetype, stock_image from stock where stock_id=?"); $sth->execute($stock_id); my @res=$sth->fetchrow_array(); print "Content-Type: $res[0]\n\n"; # display the image print "$res[1]"; # in web browser $sth->finish; } else { # stock image stored externally # ... } $dbh->disconnect();