>From your last comments, I am not sure where this is leading to, but here is
all I have to say.

Below are 2 pieces of code. Both have been tested with space in the string
and again without space. 

$limit = "$offset,$number_rows"  or $limit = "$offset, $number_rows"; 

1) This does not work (with or without space in the string).

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


2) This works fine (with or without space in the string).

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


In the first example, DBI always passed the value for offset and ignored the
second value after the comma.

I'm now using the second code as it works without problem even if string
contains space. I just need to understand why DBI behaves that way.

I cannot hard code limit in the string because the value varies. This is
used in a pager and the values of limit varies depending on which page is to
be displayed.


Reply via email to