Robert,
I suspect that your interpretation is false (see also below).
If you are within a transaction your SELECTs will show all the changes
that you made. But they will show them to you only! Nobody else can see
them for they are uncommited.
Finally you decide what to do:
Rollback discards everthing since the transcation started (and when you
connect (create a session) a transcation will be started automatically
for you in an Oracle database), but the Commit makes those changes
permanent and visible for others.
That's so beautiful about transcations: you can try out some things and
if you are satisfied with the result you commit.
Regards,
Frank.
Robert Landrum wrote:
>
> At 11:54 PM +0200 5/14/01, Nico van Leeuwen wrote:
> >Good evening,
> >
> >I have been struggeling with oracle selects all day am getting some strange
> >results.
> >
> >I can't seem to find out what is wrong with the following script:
> >
> >#!/usr/bin/perl -w
> >
> >use strict;
> >use DBI;
> >
> ># Connect to the database
> >
> >my $dbh = DBI->connect( 'dbi:Oracle:mercury.systime',
> > 'systime',
> > 'systime',
> > {
> > RaiseError => 1,
> > AutoCommit => 0
> > }
> > ) || die "Database connection not made: $DBI::errstr";
> >
> > print "connected\n";
> >
> ># Insert a new row
> >
> > $dbh->do("INSERT INTO t_user ( name, adresse, plz, land, ort, vorname )
> >VALUES( 'van Leeuwen' , 'Emmi-Welter Str 22', 52064, '0049', 'Aachen',
> >'Nico' )");
>
> You must do a commit here.
>
> $dbh->commit;
>
> > # Get the row back
> >
> > my $sth = $dbh->prepare("SELECT name, adresse, plz, ort, land, vorname
> >FROM t_user");
> >
> > $sth->execute();
> >
> > my( $name, $adresse, $plz, $ort, $land, $vorname );
> >
> > $sth->bind_columns( undef, \$name, \$adresse, \$plz, \$ort, \$land,
> >\$vorname );
> >
> > while( $sth->fetch() ) {
> >
> > print "$name, $adresse, $plz, $ort, $land, $vorname\n";
> > print "-------------------------------\n";
> >
> > }
> >
> >
> >$sth->finish();
You must do a COMMIT here if you want to make the changes (INSERT in
this case) permanent in the database ...
> >$dbh->disconnect();
... because the disconnect leads to a Rollback by the database (a
necessary clean-up after a session has been terminated willingly or
unwillingly)
> >
> >exit;
> >
>
> I generally leave autocommit on so that I don't have to remember to
> call commit. Otherwise, you could end up with abended records when
> you die without disconnect on the select statement. For instance,
> the select statement would most likely hang do to the uncommitted
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Nonsense!
> insert, which might cause someone to ^C the script resulting in an
> abended record.
>
> Hope that fixes your problem.
>
> Rob
>
> --
> As soon as you make something foolproof, someone will create a better fool.
--
Dr. Frank Ullrich, Netzwerkadministration
Verlag Heinz Heise GmbH & Co KG, Helstorfer Str. 7, D-30625 Hannover
E-Mail: [EMAIL PROTECTED]
Phone: +49 511 5352 587; FAX: +49 511 5352 538