Re: DBD::CSV and SQL::Statement issues

From: Jeff Zucker (jeff_at_vpservices.com)
Date: 05/14/04


Date: Fri, 14 May 2004 07:16:26 -0700
To: Christopher Huhn <C.Huhn@gsi.de>, dbi-users <dbi-users@perl.org>

Hi Chrisopher,

Christopher Huhn wrote:

> I'm missing the following features using DBD::CSV:
>
> * Selecting constant values isn't working (i.e. SELECT 'xyz' FROM
> table). AFAIK that's plain SQL.

Yes, it's plain SQL but not yet supported by SQL::Statement. The syntax
that is supported is listed in the SQL::Parser docs. I plan to revamp
the entire SELECT columns parsing to allow column aliases, functions,
constants, etc. but currently those aren't supported in the
select_columns clause even if they are supported in the WHERE clause.

> * There's no case insensitive IN operator (Yes, I know about CLIKE ...)

Sorry, that's not something I'll probably ever add, but this should work
now: ... WHERE UPPER(foo) IN( UPPER(bar), UPPER(baz) ).

> $sql = 'SELECT wb,from_address FROM whitelist WHERE user_id = ? '.
> 'AND from_address IN (?,?,?)';
> $sth = $dbh->prepare($sql) or die "Cannot prepare: " .
> $dbh->errstr();
> $sth->bind_param(1, '1001');
> $sth->bind_param(2, 'email1@other-domain.tld');
> $sth->bind_param(3, 'email2@third-domain.tld');
> $sth->bind_param(4, 'email3@domain4.tld');
> $sth->execute() or die "Cannot execute: " . $sth->errstr();
> DBI::dump_results($sth);
>
> leads to
>
> Use of uninitialized value in substitution iterator at
> /usr/share/perl5/SQL/Parser.pm line 974.
> SQL ERROR: Bad predicate: ''!

> ii libsql-statement-perl 1.005-1 SQL parsing

There was a bug in the IN parsing in 1.005, sorry. The current version
of SQL::Statement 1.09, works fine with that syntax.

-- 
Jeff


Relevant Pages

  • Re: CROSS JOIN
    ... > was that depreciating the original FROM .. ... WHERE syntax would never ... > The problem is that the WHERE clause is done after the FROM clause. ... but thats just outer join stuff. ...
    (comp.databases)
  • Re: Extending define with where clause
    ... > parallel to lambda*, which implements automatic handling of keyword ... "where" clause is used that the new syntax really matters. ... introduced with the help of let, letrec, letrec*, or named let -- are ...
    (comp.lang.scheme)
  • Re: Not Exists joining 2 tables
    ... "'code' is a bad name for a key column" is a valid complaint. ... EXISTS clause with a correlated subquery properly, ... SQL+ syntax and start using the ANSI SQL syntax that seems ... Then the only criteria in the where clause ...
    (comp.databases.ms-sqlserver)
  • Re: update query: still having problems
    ... Only the records from Department that have a rate value present in sheet1, ... That is how an INNER JOIN works when there is no duplicated values (in one ... you add an extra WHERE clause. ... Your code throws up a syntax error: ...
    (microsoft.public.access.queries)
  • Re: Statement parameter in Mailmerge.OpenDataSource
    ... You can certainly pass an SQL SELECT statement with a WHERE clause. ... the syntax right can be difficult, ... You may be able to find out more about that in SQL Server Books Online. ... > What i'm trying to do is, passing a statement calling a table-valued ...
    (microsoft.public.word.mailmerge.fields)