I need to compare the data in table between 2 databases. I've found an Oracle command that will do just that but I'm having difficulty implementing it in perl. Here is what I have so far:
my $sqlstr ="select table_name". " from Dba_tables". " where owner = '$schema'". " order by table_name"; my $sth=$db1->prepare($sqlstr) or print STDOUT "Query:GetDataF +ast Failed"; $sth->execute; my $table_names = $sth->fetchall_arrayref; $sth->finish; for $table_names_r (@{$table_names}) { my $sqlstr ="select column_name". " from Dba_tab_columns". " where owner = '$schema'". " and table_name = '$table_names_r->[0]'". " order by column_name"; my $sth=$db1->prepare($sqlstr) or print STDOUT "Query:GetD +ataFast Failed"; $sth->execute; my $column_names = $sth->fetchall_arrayref; $sth->finish; my $sqlstr2 ="select *". " from $schema.$table_names_r->[0]". + " MINUS". " select *". " from $schema.$table_names_r->[0]".'@'."$confi +g{database_2}"; print STDOUT "Table: $schema.$table_names_r->[0]"; my $sth2=$db1->prepare($sqlstr2) or print STDOUT "Query:Ge +tDataFast Failed"; $sth2->execute; my $results = $sth2->fetchall_arrayref; $sth2->finish;
$sqlstr2 holds the query in question. Is there another way to do this without first creating a dblink in one of the databases? I'd like to be able to do this on any set of databases without creating the dblink.

In reply to How to Compare Data in 2 Separate Databases by timo

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.