in reply to Re: Perl DBI '?' substitution with prepare/execute
in thread Perl DBI '?' substitution with prepare/execute

> There are some query builders, like SQL::Abstract, or DBIx::PreQL.

interesting any others like this and DBIx::Abstract ?

What I especially like about SQL::Abstract is that the problem of variable numbers of placeholders is addressed, it's no fun to generate strings like (?,?,?,?) for IN statements.

> In my experience, I found query builders to be too tedious, as I usually have to fight them too hard to get the SQL I want them to generate.

Maybe this could be addressed with an inner DSL in Perl ( DBIx::PreQL seems to be an outer DSL) .

Let's talk about it at our next meeting. :)

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^3: Perl DBI '?' substitution with prepare/execute (abstract SQL)
by SimonPratt (Friar) on Apr 18, 2016 at 16:25 UTC

    What I especially like about SQL::Abstract is that the problem of variable numbers of placeholders is addressed, it's no fun to generate strings like (?,?,?,?) for IN statements.

    Hmm, interesting. I'll have to take a closer look at that module. I had previously been building strings like this:

    my $insertstring = '['.join('],[', @sqlcolumns).']'; my $valuestring = join(',', map {'?'} @sqlcolumns); my $query = "INSERT INTO table ($insertstring) VALUES ($valuest +ring)";
    Which is, as you say, tedious.

      yeah but IMHO the way operators like IN are coded into hashes doesn't improve readability..

      hopefully I'll meet ribasushi soon again to discuss further, SQL is not my core domain...

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

        Hmm, I see what you mean. Also, the flexibility and mutability of the operators makes this quite a daunting API to learn.