I would like to pass a multi-level hash (which is, of course, better than multi-level marketing) to an insert statement to get some data into a Pg database.

The table is:

name    date    type    federal    active

The hash looks like:

my %holidays = ( "New Years Day" => { date => '20050101', type => 'US', federal => 'true', active => 'true', }, "Martin Luther King Day" => { date => '20050119', type => 'US', federal => 'true', active => 'true', }, "Groundhog Day" => { date => '20050202', type => 'US', federal => 'false', active => 'false', }, );

I can do simple inserts but I haven't tried anything like this before. How would I code the "insert" statement?

Humbly submitted,

Robert


In reply to Using a multi-level hash in an insert statement... by sigzero

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.