I'm already tensing myself for the downvotes :)

A few years ago, when I didn't know any better, I actually did something similar to what you're suggesting.

But I did it with the dreaded 'require'

I haven't done it since, as my skills have developed a tad since then, but it might just be a bad idea that works in your case.

What I did was this:

1.) Created a file called: queries.pl

In this file, I put things like:

$Q_FINDMAX = 'select max(note_id) from pat_notes'; $Q_FINDMIN = 'select min(note_id) from pat_notes'; . . etc...
and then, in my script: parse_notes.pl, I used:
require ('/prod/parse/queries.pl');
After that, it's just a matter of using the $Q_ variable names to refer to the queries.

The advantage of doing it this way is that it allowed the SQL folks to update/tune SQL without having to go into the actual Perl script to find them.

It's probably not the *best* way to do this sort of thing, but maybe it's good enough for what you're after? The syntax might be a little off (like I said, I haven't done this in a while, and I don't have any examples in front of me to refer to

Trek


In reply to Re: Abstracting SQL without Stored Procedures by TrekNoid
in thread Abstracting SQL without Stored Procedures by radiantmatrix

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.