>>>>> "MC" == Mimi Cafe <mimic...@googlemail.com> writes:

  MC> You asked why I am concatenating the 2 scalars, comma and the space 
below? 
  MC> my $limit = "$offset" . ', ' . "$number_rows";

  MC> I agree your suggestion below should work as well, but I was desperate to 
find the error, so I tried several option to see whether DBI will parse the 
string correctly.  

i don't see any code where there is no space after the comma.


  MC> Below I tried quoting the string as you mentioned below, but it
  MC> still didn't work as expected. MySQL has no problem if the value
  MC> for "limit" has space between the offset and number of rows as
  MC> long as there is a comma after the offset.

i don't see that at all.

  MC> LIMIT 5, 10 and LIMIT 5,10 are the same in MySQL.

  MC> # limit should be like “10, 20”.
  MC> my $limit = “$offset, $number_rows”; # $limit = “$offset,$number_rows” 
did not work as well. 

there is a space there. you claim it makes no difference but that isn't
what i see here. show the dbi log of the code without the space.

  MC> my $sth = $dbh->prepare(qq{
  MC>           Select fname, lname, dob, substr(desc, 1, 200)  from user left 
join personal_data on 
  MC>           user.id = personal_data.id where gender = ? and position = ? 
order by lname limit ?
  MC>   });

why not try to hard code the limit in that string? don't use a bind
value. there is no need for a bind here as your numbers are hard coded.

  MC> $sth->execute($gender, $role, $limit);


  MC> As can be seen in the MySQL query log below, the DBI parser
  MC> ignores the comma, space and second value and only passes the
  MC> offset to the database. In the first query the $limit variable
  MC> contained 0,10, but DBI passes only the 0 (offset value) to the db
  MC> server. The only way to get around this is for me to pass $limit
  MC> directly in the query like:

again, this is with a space. not what i asked to see.


  MC> my $sth = $dbh->prepare(qq{
  MC>           Select fname, lname, dob, substr(desc, 1, 200)  from user left 
join personal_data on 
  MC>           user.id = personal_data.id where gender = ? and position = ? 
order by lname limit $limit
  MC>   });

same thing here. i don't see the limit without the space.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to