Well I actually did it on a other way...

- I had 2 queries from a db.
- I wanted to write the results in a csv(fixed order so tie).
- But in the first query i had a key login and if this key existed in second query I wanted the data from both queries as a union on one line in the csv.(both had common fields and unique fields to the both queries)

I solved it on db-level:
- I made a new table in oracle where i put the data from query one. Then do a insert or update(to login) with second query.(first i did it with tempory tables in memory, but dumped that idea).
- Finally I read out that table and make the csv.

This solution is also good for knowing on which day what data should be in that csv. If something went wrong with creating the csv and/or sending it to the outside party. I easily can redo this step, because of this table.


For the ones who would be interested hacked a small sample, how i could do it on perl-level:
# record 1 $login = "me"; $name = "toadi"; $email = "toadi@toadi.be"; $contract = "SERVICE"; $csv{$login}{name}=$name; $csv{$login}{email}=$email; $csv{$login}{contract}=$contract; # record 2 $login = "u"; $name = "other one"; $email = "other@other.be"; $contract = "Programming"; $csv{$login}{name}=$name; $csv{$login}{email}=$email; $csv{$login}{contract}=$contract; foreach $login ( keys %csv ) { print "$csv{$login}{name},$csv{$login}{email},$csv{$login}{rek +nr},$csv{$login}{contract}\n"; }
So if the key exits, it will write over the needed values. If key not exits it wil make a new entry...

--
My opinions may have changed,
but not the fact that I am right


In reply to Re: Re: Uniion of 2 hashes don't work. by toadi
in thread Union of 2 hashes don't work. by toadi

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.