I posted a snippet a while ago that shows one method of generating an SQL INSERT statement from an anonymous hash and a table name, which is about as simple as you can get. Plus it does clever things to produce placeholdered statements and batched commits.

It really is a funky piece of code that serves me well. OTOH it only works well in a limited domain, that is, it is not the ideal solution when you are inserting different columns sets at different points in the program (as it must generate a fresh prepared statement for each call and it's up to you to remember to tell it to do so).

So I think it would be hard to come up with something that satisfies the general case.

Plus, my main aim was to minimise characters. Not in a golf TM sense, but I didn't want to have to dick around with too many braces, parens or other syntactic fluff.

An example call looks like this:

insert 'aglrelvalue', { att_value => $id_mission, attribute_id => B0, client => DEFCLIENT, last_update => $mis_update, percentage => 100.00, rel_attr_id => YC, rel_value => $regvp, user_id => USER, };

--
g r i n d e r

In reply to Re: Architecture of a Database system by grinder
in thread Architecture of a Database system by Boldra

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.