Answer to Question #22425 in Perl for Sandeep Saxena
Ques 1 :
Sample Code
Code:
INSERT INTO names VALUES ('John')
How do you use the DBI module to execute the above SQL statement? Assume $dbh is the return value from DBI->connect.
Choice 1
my $statement = $dbh->execute("INSERT INTO names VALUES ('John')");
Choice 2
my $statement = $dbh->sql("INSERT INTO names VALUES ('John')");
$statement->execute;
Choice 3
my $statement = $dbh->prepare("INSERT INTO names VALUES ('John')");
$statement->execute;
Choice 4
my $statement = $dbh->run("INSERT INTO names VALUES ('John')");
Choice 5
my $statement = $dbh->insert("INSERT INTO names VALUES ('John')");
$statement->finish;
Ques 2 :
What is the output of the following script?
#!/usr/local/bin/perl
$i = 0; $j = 1;
if ($i = 2) { print $i; }
else { print $j; }
if ($i = 0) { print $i; }
else { print $j; }
(a) 11
(b) 21
(c) 10
(d) 01
(e) It produces an error message.
0
Answer in progress...
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
Perl
Comments
Leave a comment