From: Pepe TD Vo <pepevo@yahoo.com>
To: Pgsql-admin <pgsql-admin@postgresql.org>
Subject: can't call function to delete the table
Date: Mon, 14 Oct 2019 16:27:31 +0000 (UTC)
Message-ID: <292566289.866009.1571070451686@mail.yahoo.com> (raw)
References: <292566289.866009.1571070451686.ref@mail.yahoo.com>
Hello Experts,
Would you please help me why I can't call the function to delete table and insert data from another table? Simple deletion and insert from one to other are fine
DELETE FROM bnft_hist_actn_ldim;
INSERT INTO bnft_hist_actn_ldim SELECT stg.bnft_hist_actn_id, stg.bnft_hist_actn_src_cd, stg.bnft_hist_actn_desc, stg.mig_filenameFROM stg_bnft_hist_actn_ldim stg;
-----but when I put in the stored function, it's not working.
My stored function script is:
CREATE OR REPLACE FUNCTION pr_mig_stg_bnft_hist_actn_ldim(OUT v_Ret integer)AS $$
DECLARE v_ErrorCode varchar(32); v_ErrorMsg varchar(512); v_Module varchar(32) = 'pr_mig_stg_bnft_hist_actn_ldim'; BEGIN
DELETE FROM bnft_hist_actn_ldim;
INSERT INTO bnft_hist_actn_ldim SELECT stg.bnft_hist_actn_id, stg.bnft_hist_actn_src_cd, stg.bnft_hist_actn_desc, stg.mig_filename FROM stg_bnft_hist_actn_ldim stg;
RETURN NEW;
v_Ret := SQLSTATE;
exception when others then v_ErrorCode := SQLSTATE; v_ErrorMsg := SQLERRM; v_Ret := v_ErrorCode;
PERFORM pr_write_error_log ();
END;$$ LANGUAGE 'plpgsql';
SELECT pr_mig_bnft_hist_actn_ldim();
execute the store funtion no error but two tables are the same and didn't delete and/or insert any from one to other;
thank you for looking into it.
v/r,
Bach-Nga
No one in this world is pure and perfect. If you avoid people for their mistakes you will be alone. So judge less, love and forgive more.To call him a dog hardly seems to do him justice though in as much as he had four legs, a tail, and barked, I admit he was, to all outward appearances. But to those who knew him well, he was a perfect gentleman (Hermione Gingold)
**Live simply **Love generously **Care deeply **Speak kindly.*** Genuinely rich *** Faithful talent *** Sharing success
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: pepevo@yahoo.com
Subject: Re: can't call function to delete the table
In-Reply-To: <292566289.866009.1571070451686@mail.yahoo.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