develooper Front page | perl.perl5.porters | Postings from March 2000

Re: hook for qs// operator for embedded SQL?

Greg Bacon
March 20, 2000 06:51
Re: hook for qs// operator for embedded SQL?
Message ID:
In message <>,
    "Joseph N. Hall" writes:

: On Mon, 20 Mar 2000 08:15:43 +0000 (M.J.T. Guy) wrote:
: * Saving two quote characters doesn't seem like a big deal.   Or perhaps
: * you want to invent SQL-requests-as-objects?
: Well, yes, first you could (in theory) make interpolation context-sensitive.
: Again:
:   @result = qs/select @cols from $table where $col = $val/
: Here, @cols needs to be ,-separated, $table and $col need one kind of
: interpolation, and $val needs another.  It's certainly not unreasonable
: to assume that a future qs// could be smart enough to recognize this
: much SQL.

Do DBI placeholders handle that sort of thing?  How hard would it be to
extend them to do so?  Then your only hurdle would be syntactical.

: You p5p-ers may or may not understand the significance and popularity of
: SQL and Perl but from my contact with the real world, it's headed toward
: "huge."  A few syntactical nods in its direction will likely make Perl
: many new friends a year or two down the road.

I've only used DBI (as opposed to, say, Pro*C and friends) when talking
to databases, so I have no idea what outsiders might want or expect
(though reading people's code in *.pc makes me see that particular
implementation as being rigid and inflexible).  Oh, wait, we're
currently working on a project where we're using Java (retch!) to talk
to a database loaded down with monolithic feature and metadata tables.
I'd much rather be creating statement handles. :-)

You'd already have Rule 1 support for allowing people to write embedded
SQL (or any other language) once they've invoked the correct module or
pragma.  This is mainly a DBI issue.  It's tangentially a Perl issue in
that it would be cool to be able to either augment Perl's grammar or
entirely substitute another.

What sorts of expectations are you finding?  What sorts of complaints
do people have about using DBI?

: Frankly I think it would be good to reserve the entire qc (where c is
: some lowercase alpha) namespace and quote-op syntax.

It would be cool to be able to tell the compiler that a subroutine is
a quoting operator (for cool delimiter behavior) with early or late
binding semantics, e.g.,

    # turtles up if you loved Logo :-)
    sub qs :quote :late { ... }

    qs/delete from existence where fname='Bill' and lname='Gates'/;

Greg Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About