467,926 Members | 1,744 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,926 developers. It's quick & easy.

perl DBI doubt

Expand|Select|Wrap|Line Numbers
  1. $sth = $dbh->prepare("select count(*) from test where status = 1 and name= '$name");
  2.     $sth->execute();
How do I change the above statement so that the variable $name can be avoided inside a prepare statement as it is a vraible.

Thanks.
Aug 8 '08 #1
  • viewed: 960
Share:
4 Replies
eWish
Expert 512MB
What do you mean by "avoided"?

--Kevin
Aug 8 '08 #2
How to pass variables in sql prepared statement? Is there any other means of doing it?
Aug 8 '08 #3
Yes Thx. I could do it as below:

Expand|Select|Wrap|Line Numbers
  1. $sth = $dbh->prepare("select count(*) from test where status = 1 and name=?");
  2. $sth->execute($name);
Aug 8 '08 #4
eWish
Expert 512MB
Placeholders and Bind Values

Expand|Select|Wrap|Line Numbers
  1. my $sql = $dbh->prepare(q{SELECT name FROM test  WHERE user_id = (?)});
  2.    $sql->execute($user_id);
--Kevin
Aug 8 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Premshree Pillai | last post: by
31 posts views Thread by surfunbear | last post: by
1 post views Thread by sm00thcrimnl13 | last post: by
1 post views Thread by Babu | last post: by
82 posts views Thread by Edward Elliott | last post: by
2 posts views Thread by sandhya2006 | last post: by
8 posts views Thread by =?UTF-8?B?4LSc4LSX4LSo4LWN4LSo4LS+4LSl4LWN?= | last post: by
2 posts views Thread by sasimca007 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.