Take this to [EMAIL PROTECTED] (I'm just getting back from vacation, real 
responses delayed until we finish getting everything back in order at the 
house). First recommendation is of course, don't try to assign something to 
$_ directly, but maybe that's just my personal take (I'd have used another 
var, any other var).

On Sunday 26 June 2005 23:55, Anthony Gorecki wrote:
> Hello,
>
> I've been encountering an unusual string of errors while attempting to
> retrieve information from a database using DBD-mysql-2.9007 and
> mysql-4.1.12. The database in question is of type InnoDB. Below is an
> example:
>
> #!/usr/bin/perl -w
>
> use strict;
> use DBI;
>
> my $db_conn = DBI->connect('DBI:mysql:infrastructure', 'system',
> 'readonly'); if (!$db_conn) {
>     error('The program was unable to connect to the database.');
> }
>
> $_ = $db_conn->selectrow_array("
>     SELECT [EMAIL PROTECTED] := (
>         SELECT user_id FROM users WHERE username = 'agorecki' LIMIT 1)
>     );
> ");
>
> if (!defined($_)) {
>     $db_conn->disconnect();
>     error('It appears that the user account has disappeared since login '.
>         'time...'
>     );
> }
>
>
> The same query in MySQL will return the session variable, however DBD-mysql
> returns undefined. Similarly, when I run:
>
> SELECT type
> FROM svn_access
> WHERE 'test' REGEXP REPLACE(path_regex, '\$USERNAME\$', 'agorecki') = 1
>     AND (user_id = @user_id
>         OR group_id = ANY (SELECT group_id FROM group_memberships WHERE
>             user_id = @user_id)
>         OR (user_id IS NULL AND group_id IS NULL)
>     )
> ORDER BY type DESC LIMIT 1;
>
>
> through selectrow_array (properly encoded for use in a PERL script), I also
> receive an undefined result. The above query correctly returns one row when
> input into a MySQL console and executed.
>
> The only thing that actually managed to execute and return a value
> successfully was:
> $_ = $db_conn->selectrow_array("SELECT 'hello';");
>
> Any thoughts?

-- 
-----o()o---------------------------------------------
Michael Cummings   |    #gentoo-dev, #gentoo-perl
Gentoo Perl Dev    |    on irc.freenode.net 
-----o()o---------------------------------------------

Attachment: pgpP5xMYhqA2V.pgp
Description: PGP signature

Reply via email to