While using perl to make some DBI calls to a PostgreSQL database, I realized that many's the time when I select data from a view, or use a function/stored procedure. Naturally, the functions/SPs are in SQL or PL/pgSQL, and the selection and final presentation of the data is handled by perl. Now, with some new advances in PL/Perl, -- a perl-based procedural language for PostgreSQL -- I started to think about Where Things Are Done.

Correlated subqueries lend themselves nicely to being rewritten into functions/SPs using PL/pgSQL, rather than downloading messy blocks of data into memory only to be subsequently discarded.

Regular expression processing is loved by perl. So perl might be used for data validation -- implemented in PL/Perl as a trigger, thereby letting the database handle the atomicity of the transaction; rather than validating in perl, using DBI to insert, using PL/pgSQL to verify, and then possibly roll the whole thing back across a span of different languages and routines.

It appears that where things are done is becoming less of a restriction and more of a personal choice, based on a number of factors unique to the individual problem domain's specific solution criteria.

So, which method/s would you use?

And why?

Contemplatively,
-v.
"Perl. There is no substitute."

In reply to Perl, PostgreSQL, and Where Things Are Done by Velaki

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.