Skip to content

having cannot have > or < #14

Open
@Tux

Description

@Tux

Lest we forget ...

use 5.18.2;
use warnings;
use Text::CSV_XS qw( csv );
use DBI;

my $tbl = "issue$$";

csv (out => "$tbl.csv", in => [
    [qw( c_issue issue color size )],
    [1,234,"Black",4],
    [2,345,"Red",8],
    [3,345,"Pink",8],
    [4,456,"White",16]]);

my $dbh = DBI->connect ("dbi:CSV:", undef, undef, {
    RaiseError		=> 1,
    PrintError		=> 1,
    ShowErrorStatement	=> 1,
    f_ext		=> ".csv/r",
    }) or die DBI->errstr;
my $sth = $dbh->prepare (qq;
    select   issue, count (*)
    from     $tbl
    group by issue
    having   count (*) > 1;
    );
$sth->execute;
while (my @row = $sth->fetchrow) {
    say "@row";
    }

END { unlink "$tbl.csv"; }

=>

$ perl -MV=Text::CSV_XS,DBI,DBD::File,SQL::Statement
Text::CSV_XS
        /pro/lib/perl5/site_perl/5.24.0/x86_64-linux-thread-multi-ld/Text/CSV_XS.pm: 1.27
DBI
        /pro/lib/perl5/site_perl/5.24.0/x86_64-linux-thread-multi-ld/DBI.pm: 1.636
DBD::File
        /pro/lib/perl5/site_perl/5.24.0/x86_64-linux-thread-multi-ld/DBD/File.pm: 0.44
SQL::Statement
        /pro/lib/perl5/site_perl/5.24.0/SQL/Statement.pm: 1.410
$ perl issue.pl
Bad table or column name: '>' has chars not alphanumeric or underscore! at /pro/lib/perl5/site_perl/5.24.0/SQL/Statement.pm line 90.
DBD::CSV::db prepare failed: Bad table or column name: '>' has chars not alphanumeric or underscore! at /pro/lib/perl5/site_perl/5.24.0/SQL/Statement.pm line 90.
 [for Statement "
    select   issue, count (*)
    from     issue31889
    group by issue
    having   count (*) > 1"] at issue.pl line 23.
DBD::CSV::db prepare failed: Bad table or column name: '>' has chars not alphanumeric or underscore! at /pro/lib/perl5/site_perl/5.24.0/SQL/Statement.pm line 90.
 [for Statement "
    select   issue, count (*)
    from     issue31889
    group by issue
    having   count (*) > 1"] at issue.pl line 23.

Activity

Tux

Tux commented on Jun 26, 2017

@Tux
MemberAuthor

ping?

rehsack

rehsack commented on Jun 26, 2017

@rehsack
Member

I can take a look (usually it's better to open issues via RT) together with all the other DBI tasks I've scheduled, but I cannot promise to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      having cannot have > or < · Issue #14 · perl5-dbi/SQL-Statement