So, the intent is to print out a well-formed sql statement by running a command with table and field names as command-line args, and your point is that you want this approach to work for a variety of distinct sql statements. And you think you need a different perl script (using a different inventory of args) for each distinct statement?

I would think you could do everything with a single script, and a bunch of distinct sql templates stored as plain text files; you could put commentary in the templates so that when the arg inventory on the command line happens to be inappropriate for the given template file, the poor user can get a clue as to what the correct usage should be. Just add the template file name as the first arg in the command usage.

This approach could save a lot of typing on the command line, since the sql template files can contain actual field names (things that don't change when the query is used repeatedly), and you only need args (and placeholders in the templates) for conditional values (things that are different just about every time the query is used).

But having said that, I look at your example again and scratch my head -- I don't understand what you're really doing... The command line args are supposed to provide the table name and field names, and the conditional values ('336%', etc) are hard coded? That seems backwards.

I wonder if this might explain why you have a (perhaps large) number of distinct "SQL generator" scripts -- the part that should be parameterized is scripted, and vice-versa.

(And I wonder what this has to do with being unix-oriented.)


In reply to Re: Getting the DATA section of one module in the import() of another by graff
in thread Getting the DATA section of one module in the import() of another by princepawn

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.