Answer to Question #22425 in Perl for Sandeep Saxena

Question #22425
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
Expert's answer

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS