Thank you. I add more information:
* Your hardware configuration and environment.
My client host :192.168.11.12 ,and the SqlServer DB server:192.168.11.16 .They located at some place.
* Your disk system(s).
My client host HD:300G.
* Your database engine's configuration.
DB is charged by our DBA.I really don't know what's config you means
* The structure of your database instance (definition of tables, indices, and objects).
Table Definition:
test_c (ID int not null,cust_id int not null,status char(1) null,money decimal(12,2) null)
no indices
* The nature of the data you are inserting.
My data is from my client host's sqlite DB
* The client script you use to access your database.
My Code :
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $mydbh = DBI->connect( "dbi:SQLite:/root/loc.db","","",{AutoCo
+mmit => 0} ) or die "Error $DBI::errstr \n";
my $dbh = DBI->connect( "dbi:Sybase:server=192.168.11.16;databa
+se=customer",
"xxx",
"xxx",
{AutoCommit =>1})
or die $DBI::errstr;
insert_it();
$mydbh->disconnect;
$dbh->disconnect;
exit;
##########################
sub insert_it() {
my $r = get_data();
for (keys %$f) {
my $mo = $r->{$_}->{money};
my $status= $r->{$_}->{status};
$dbh->do(qq{insert into test_c(custid,money,status) values
+ ($_,'$mo','$status')}) or die $DBI::errstr;
}
}
sub get_data {
my %data;
my $sth = $mydbh->prepare(qq{select custid,money,status from tem
+p_test order by custid});
my ($cid,$mon,$sta);
$sth->execute() or die $DBI::errstr;
$sth->bind_columns(undef, \$cid, \$mon, \$sta);
while ( $sth->fetch() ) {
$data{$cid} = {money => $bal, status => $sta};
}
return \%data;
}
I have tried the
placeholder method,but the sqlserver 2K doesn't support it.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.