in reply to Re: Increment DB using Perl
in thread Increment DB using Perl
#!/usr/bin/perl -w use strict; use DBI; # Set up database connection my $user = "content"; my $pass = "content"; my $dbh = DBI->connect("DBI:ODBC:LocalServer",$user, $pass, {RaiseErro +r => 1}); my $dbh2 = DBI->connect("DBI:ODBC:LocalServer",$user, $pass, {RaiseErr +or => 1}); my $new_id = 0; my $sql = "select id from request"; my $sql2 = ''; my $sth = $dbh->prepare($sql); my $sth2 = ''; my $sql_data = ($sth->execute() || die $sth->errstr); while (my $pointer = $sth->fetchrow_hashref) { $new_id++; $sql2 = "UPDATE request SET ID='$new_id'"; $sth2 = $dbh2->prepare($sql2); $sth2->execute() || die $sth2->errstr; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Increment DB using Perl
by jZed (Prior) on Mar 08, 2005 at 16:38 UTC | |
by Anonymous Monk on Mar 08, 2005 at 16:43 UTC | |
by jZed (Prior) on Mar 08, 2005 at 16:46 UTC | |
by Anonymous Monk on Mar 08, 2005 at 16:55 UTC | |
by jZed (Prior) on Mar 08, 2005 at 16:58 UTC | |
| |
|
Re^3: Increment DB using Perl
by RazorbladeBidet (Friar) on Mar 08, 2005 at 16:41 UTC | |
by Anonymous Monk on Mar 08, 2005 at 16:45 UTC | |
by RazorbladeBidet (Friar) on Mar 08, 2005 at 16:49 UTC | |
|
Re^3: Increment DB using Perl
by Joost (Canon) on Mar 08, 2005 at 16:44 UTC |