pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: query can't merge into table of the other schema
Date: Wed, 7 Nov 2018 16:22:19 -0600
Message-ID: <c56d9a46-be49-eac3-f3c3-efd76240aea6@gmail.com> (raw)
In-Reply-To: <1425722754.312953.1541603425493@mail.yahoo.com>
References: <1425722754.312953.1541603425493.ref@mail.yahoo.com>
	<1425722754.312953.1541603425493@mail.yahoo.com>

On 11/07/2018 09:10 AM, Pepe TD Vo wrote:
[snip]
>
> *ERROR: "cidrdba.sc_date_in" is not a known variable*

That doesn't look like a "can't merge table from another schema" error.

> *LINE 13:    MERGE INTO cidrdba.sc_date_in prod*
> *               ^*
> *SQL state: 42601*
> *Character: 352*

What happens when you run the statement through psql?

MERGE INTO cidrdba.sc_date_in prod
USING (
         SELECT Receipt_Number,date_in,
                mig_filename,mig_insert_dt,
                mig_modified_dt
         FROM cidr_staging.STG_Date_In
         ORDER by mig_seq
       ) stg
ON ( prod.receipt_number = stg.receipt_number )
WHEN MATCHED THEN UPDATE SET
--   prod.Receipt_Number     = stg.Receipt_Number,
    prod.Date_In              = stg.Date_In,
    prod.mig_filename         = stg.mig_filename,
    --prod.mig_insert_dt      = stg.mig_insert_dt,
    --prod.mig_modified_dt    = stg.mig_modified_dt
    prod.mig_modified_dt      = sysdate
WHEN NOT MATCHED THEN INSERT
         (
                 prod.Receipt_Number,
                 prod.Date_In,
                 prod.mig_filename,
                 prod.mig_insert_dt,
                 prod.mig_modified_dt
         ) VALUES (
                 stg.Receipt_Number,
                 stg.Date_In,
                 stg.mig_filename,
                 sysdate,
                 --stg.mig_insert_dt,
                 null
                 --stg.mig_modified_dt
         )
;


-- 
Angular momentum makes the world go 'round.

view thread (8+ messages)  latest in thread

Message-ID: <c56d9a46-be49-eac3-f3c3-efd76240aea6@gmail.com>
Permalink:  ../c56d9a46-be49-eac3-f3c3-efd76240aea6@gmail.com/
Also on:    postgresql.org/message-id/c56d9a46-be49-eac3-f3c3-efd76240aea6@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: ronljohnsonjr@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: query can't merge into table of the other schema
  In-Reply-To: <c56d9a46-be49-eac3-f3c3-efd76240aea6@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox