iis and dbi

Discussion in 'Perl Misc' started by John Giblin, Jul 10, 2003.

  1. John Giblin

    John Giblin Guest

    Hi,

    I am making a simple program that connects to Oracle and then display the
    results. When I exec the program via command like, there does not seem to
    be a problem. When I do it through a browser I do not get any print commands
    past the connection

    here is what I have:
    use strict;
    use DBI;

    my ($dbh, $sth, @row);
    my %attr = (
    PrintError => 0,
    RaiseError => 0,
    );
    $ENV{"ORACLE_HOME"}="F:/oracle/ora92";


    print "Content-type:text/html\n\n";
    print <<HEADER;
    <HTML>
    <HEAD>
    <TITLE>A Test Page</TITLE>
    </HEAD>
    <BODY BGCOLOR ="#FFFFFF" TEXT="#000000">
    <P>
    HEADER


    print "Connecting to DB..<br>\n";
    $dbh = DBI->connect( 'dbi:Oracle:Mysid','SYSTEM','pawel', \%attr)
    or die "Can't connect to database: $DBI::errstr\n";
    print "Connected<br>\n";
    print "Create sql statement<br>\n";


    $sth = $dbh->prepare( "SELECT * FROM Scott.dept" )
    or die "Can't prepare SQL statement: $DBI::errstr\n";

    print "Exec sql statement<br>\n";

    $sth->execute
    or die "Can't execute SQL statement: $DBI::errstr\n";

    ### Retrieve the returned rows of data
    while ( my @row = $sth->fetchrow_array() ) {
    print "Row: @row\n";
    }

    warn "Data fetching terminated early by error: $DBI::errstr\n"
    if $DBI::err;


    $dbh->disconnect();

    Results in a browser:
    Connecting to DB..
     
    John Giblin, Jul 10, 2003
    #1
    1. Advertising

  2. In article <YyhPa.24090$>,
    "John Giblin" <> wrote:

    > Hi,
    >
    > I am making a simple program that connects to Oracle and then display the
    > results. When I exec the program via command like, there does not seem to
    > be a problem. When I do it through a browser I do not get any print commands
    > past the connection
    >
    > here is what I have:
    > use strict;
    > use DBI;
    >
    > my ($dbh, $sth, @row);
    > my %attr = (
    > PrintError => 0,
    > RaiseError => 0,
    > );
    > $ENV{"ORACLE_HOME"}="F:/oracle/ora92";
    >
    >
    > print "Content-type:text/html\n\n";
    > print <<HEADER;
    > <HTML>
    > <HEAD>
    > <TITLE>A Test Page</TITLE>
    > </HEAD>
    > <BODY BGCOLOR ="#FFFFFF" TEXT="#000000">
    > <P>
    > HEADER
    >
    >
    > print "Connecting to DB..<br>\n";
    > $dbh = DBI->connect( 'dbi:Oracle:Mysid','SYSTEM','pawel', \%attr)
    > or die "Can't connect to database: $DBI::errstr\n";
    > print "Connected<br>\n";
    > print "Create sql statement<br>\n";
    >
    >
    > $sth = $dbh->prepare( "SELECT * FROM Scott.dept" )
    > or die "Can't prepare SQL statement: $DBI::errstr\n";
    >
    > print "Exec sql statement<br>\n";
    >
    > $sth->execute
    > or die "Can't execute SQL statement: $DBI::errstr\n";
    >
    > ### Retrieve the returned rows of data
    > while ( my @row = $sth->fetchrow_array() ) {
    > print "Row: @row\n";
    > }
    >
    > warn "Data fetching terminated early by error: $DBI::errstr\n"
    > if $DBI::err;
    >
    >
    > $dbh->disconnect();
    >
    > Results in a browser:
    > Connecting to DB..


    try:

    use strict;
    use DBI;
    use CGI::Carp qw/fatalsToBrowser/;

    my ($dbh, $sth, @row);
    my %attr = (
    PrintError => 1,
    RaiseError => 1,
    );

    etc.

    hth
    --
    Michael Budash
     
    Michael Budash, Jul 10, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Giblin

    iis dbi

    John Giblin, Jul 10, 2003, in forum: Perl
    Replies:
    0
    Views:
    1,230
    John Giblin
    Jul 10, 2003
  2. ulloa
    Replies:
    1
    Views:
    527
    Juha Laiho
    Jul 22, 2004
  3. Jerome Hauss
    Replies:
    0
    Views:
    172
    Jerome Hauss
    Oct 13, 2004
  4. Asby

    Mason, DBI, and DBI::Pg

    Asby, Jul 24, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    177
  5. Tim Haynes
    Replies:
    3
    Views:
    143
    Ron Reidy
    Sep 13, 2003
Loading...

Share This Page