Hello,
I have one perl code.
'
Here they are using oracle database. To extract that data from database they are using DBI module.
in this program they have used some queries also.
i have such proram here here
in query they have used
? ? ? but i do not know what is this questions maks.
please can any one exaplain me the usage of this question mark inside the query.
[CODE=perl]use strict;
use DBI qw(:sql_types);
my $dbh = DBI->connect( 'dbi:Oracle:orc l',
'jeffrey',
'jeffspassword' ,
{
RaiseError => 1,
AutoCommit => 0
}
) || die "Database connection not made: $DBI::errstr";
my @records = (
[ 0, "Larry Wall", "Perl Author", "555-0101" ],
[ 1, "Tim Bunce", "DBI Author", "555-0202" ],
[ 2, "Randal Schwartz", "Guy at Large", "555-0303" ],
[ 3, "Doug MacEachern", "Apache Man", "555-0404" ]
);
my $sql = qq{ INSERT INTO employees VALUES ( ?, ?, ?, ? ) };my $sth = $dbh->prepare( $sql );
for( @records ) {
eval {
$sth->bind_param( 1, @$_->[0], SQL_INTEGER );
$sth->bind_param( 2, @$_->[1], SQL_VARCHAR );
$sth->bind_param( 3, @$_->[2], SQL_VARCHAR );
$sth->bind_param( 4, @$_->[3], SQL_VARCHAR );
$sth->execute();
$dbh->commit();
};
if( $@ ) {
warn "Database error: $DBI::errstr\n" ;
$dbh->rollback(); #just die if rollback is failing
}
}
$sth->finish();
$dbh->disconnect() ;[/CODE]
shafi
I have one perl code.
'
Here they are using oracle database. To extract that data from database they are using DBI module.
in this program they have used some queries also.
i have such proram here here
in query they have used
? ? ? but i do not know what is this questions maks.
please can any one exaplain me the usage of this question mark inside the query.
[CODE=perl]use strict;
use DBI qw(:sql_types);
my $dbh = DBI->connect( 'dbi:Oracle:orc l',
'jeffrey',
'jeffspassword' ,
{
RaiseError => 1,
AutoCommit => 0
}
) || die "Database connection not made: $DBI::errstr";
my @records = (
[ 0, "Larry Wall", "Perl Author", "555-0101" ],
[ 1, "Tim Bunce", "DBI Author", "555-0202" ],
[ 2, "Randal Schwartz", "Guy at Large", "555-0303" ],
[ 3, "Doug MacEachern", "Apache Man", "555-0404" ]
);
my $sql = qq{ INSERT INTO employees VALUES ( ?, ?, ?, ? ) };my $sth = $dbh->prepare( $sql );
for( @records ) {
eval {
$sth->bind_param( 1, @$_->[0], SQL_INTEGER );
$sth->bind_param( 2, @$_->[1], SQL_VARCHAR );
$sth->bind_param( 3, @$_->[2], SQL_VARCHAR );
$sth->bind_param( 4, @$_->[3], SQL_VARCHAR );
$sth->execute();
$dbh->commit();
};
if( $@ ) {
warn "Database error: $DBI::errstr\n" ;
$dbh->rollback(); #just die if rollback is failing
}
}
$sth->finish();
$dbh->disconnect() ;[/CODE]
shafi
Comment