merge into using perl from array

  • From: Barbara Baker <barb.baker@xxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Tue, 18 Aug 2009 14:58:37 -0600

Does anyone have an example that uses the "merge into" syntax where the
source would be an array in perl instead of a "real" table?  Is it
possible?  Oracle 9.2.0.7 Sun O/S 9 perl 5.8.5

Here's sorta what I'm trying to do:

merge into
  ffcst.user_auth tgt
using
  ad_mart.sales_dim@prod_reader  src
on (src.sales_sid=tgt.sales_sid)
when matched then
  update set tgt.sales_rep_code = src.sales_rep_code
when not matched
then
  insert (tgt.rep_first_name)
values (  src.rep_first_name)
;

I'm getting the max timestamp
$sth = $dbh->prepare( "
        SELECT  max(import_stamp) FROM plate_rpt
        " );

  unless ( $sth->execute() ) {
    $ResultMsg = "Select Max Timestamp from $db plate_rpt table failed";

    ToLog($log,$ResultMsg);
    return($ResultMsg,\@row);
    }
  @row = $sth->fetchrow();

Then I'm
     selecting records from plate_counts
     where to_char(stamp, 'YYYY-MM-DD HH24:MI:SS') > '$last_ts'

and now I want to merge/insert the records I've found, but they're in
memory.

Thanks for any ideas.  Let me know if I'm crazy.  (well, ok, that ship has
sailed)

Barb

Other related posts: