Coder Social home page Coder Social logo

sql-statement's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sql-statement's Issues

Deep recursion on subroutine "SQL::Parser::non_parens_search"

We have created an SQL UPDATE statement with a WHERE clause that has ORed 239 conditions. We are getting

Deep recursion on subroutine "SQL::Parser::non_parens_search"

because SQL::Parser escalates all warnings into fatal errors. Any suggestion how we could turn this off from case to case would be very much appreciated?

having cannot have > or <

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.

Table 'AR_X_AGN_REESTR_1' referenced but not found in FROM list (HTF13.AR_X_AGN_REESTR_1,HTF13.AR,ar)! at C:/Dwimperl/perl/site/lib/SQL/Statement.pm line 88

my $sql ="SELECT AR.*
FROM
HTF13.AR AR LEFT OUTER JOIN HTF13.AR_X_AGN_REESTR_1
ON
HTF13.AR_X_AGN_REESTR_1.CST_AR_ID = AR.AR_ID AND
HTF13.AR_X_AGN_REESTR_1.CST_SUB_AR_ID = AR.AR_ID
WHERE
AR.AR_PPS_TP_ID = 1527 AND
AR.AR_TP_ID <> 1467 AND
HTF13.AR_X_AGN_REESTR_1.CST_AR_ID IS NULL

"
;

use SQL::Statement;
my $parser = SQL::Parser->new();
$parser->{RaiseError} = 1;
$parser->{PrintError} = 1;

my $stmt = SQL::Statement->new($sql, $parser);

printf("( %s => %s ) \n",, '', join(',', map { $_->name } $stmt->tables()));

Can't use OR in an ON clause! at C:/Dwimperl/perl/site/lib/SQL/Statement.pm line 88

my $sql ="SELECT AR.*
FROM
HTF13.AR AR LEFT OUTER JOIN HTF13.AR_X_AGN_REESTR_1
ON
HTF13.AR_X_AGN_REESTR_1.CST_AR_ID = AR.AR_ID OR
HTF13.AR_X_AGN_REESTR_1.CST_SUB_AR_ID = AR.AR_ID
WHERE
AR.AR_PPS_TP_ID = 1527 AND
AR.AR_TP_ID <> 1467 AND
HTF13.AR_X_AGN_REESTR_1.CST_AR_ID IS NULL

"
;

use SQL::Statement;
my $parser = SQL::Parser->new();
$parser->{RaiseError} = 1;
$parser->{PrintError} = 1;

my $stmt = SQL::Statement->new($sql, $parser);

printf("( %s => %s ) \n",, '', join(',', map { $_->name } $stmt->tables()));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.