pg_sql | Unsorted

Telegram-канал pg_sql - PostgreSQL

2830

English speaking PostgreSQL public chat. This group is for discussions on PostgreSQL-related topics and strives to provide best-effort support as well.

Subscribe to a channel

PostgreSQL

-- Create the trigger function
CREATE OR REPLACE FUNCTION log_material_changes()
RETURNS TRIGGER AS $$
DECLARE
    v_action TEXT;
    v_old_value TEXT;
    v_new_value TEXT;
    v_field TEXT;
    v_user_name TEXT;
    v_mpn TEXT;
    v_spn TEXT;
    v_physicaltype TEXT;
BEGIN
    -- Determine the action type
    IF TG_OP = 'INSERT' THEN
        v_action := 'CREATE';
        v_old_value := NULL;
        v_new_value := ROW(NEW.*)::TEXT;  -- Capturing new values
    ELSIF TG_OP = 'UPDATE' THEN
        v_action := 'MODIFY';
        v_old_value := ROW(OLD.*)::TEXT;  -- Capturing old values
        v_new_value := ROW(NEW.*)::TEXT;  -- Capturing new values
    ELSIF TG_OP = 'DELETE' THEN
        v_action := 'DELETE';
        v_old_value := ROW(OLD.*)::TEXT;  -- Capturing old values
        v_new_value := NULL;
    END IF;
 
    -- Assume user information and other context is available through session variables or application context
    v_user_name := current_user;  -- Modify this line if user context is provided differently
    v_mpn := COALESCE(NEW.manufacturer_part_number, OLD.manufacturer_part_number);
    v_spn := COALESCE(NEW.supplier_part_number, OLD.supplier_part_number);
    v_physicaltype := COALESCE(NEW.physicaltype, OLD.physicaltype);
 
    -- Insert the log record into pm_change_logs
    INSERT INTO pm_change_logs (
        moduleaction, user_id, created_at, updated_at, is_deleted, item_id,
        old_value, new_value, field, date, user_name, approver, mpn, spn,
        physicaltype, comments
    )
    VALUES (
        'material_detail_stg', v_action, NULLCURRENT_TIMESTAMPCURRENT_TIMESTAMP,
        FALSECOALESCE(NEW.item_id, OLD.item_id), v_old_value, v_new_value,
        NULLCURRENT_TIMESTAMP, v_user_name, NULL, v_mpn, v_spn,
        v_physicaltype, NULL
    );
 
    RETURN NEW;
END;
$$ LANGUAGE plpgsql;
 
-- Create the trigger on material_detail_stg table
CREATE TRIGGER trg_material_changes
AFTER INSERT OR UPDATE OR DELETE ON material_detail_stg
FOR EACH ROW EXECUTE FUNCTION log_material_changes();

Читать полностью…

PostgreSQL

Hi, need help from someone to check if a trigger function i have written is correct

Читать полностью…

PostgreSQL

Any document for PostgreSQL upgrade on AWS RDS ?

Читать полностью…

PostgreSQL

Hey everyone,

I’ve been working as a DBA/Data Engineer for the past 6 years, and I’m trying to figure out what area I should enrich my knowledge in during my free time. I work with PostgreSQL, MySQL, and MongoDB (both infrastructure and application-level). I mainly use NiFi and Python, and I work in AWS, GCP, and on-premises environments.

I have above-average knowledge of Linux, so I’m capable of handling many tasks that fall under IT/DevOps roles independently. I’ve mostly learned everything on my own, and now I’m looking for areas where I should deepen my expertise or learn something new.

I’m considering the following options and would appreciate your help:

Learn Oracle
Get AWS/GCP Certification as a Cloud Data Engineer
Continue specializing in PostgreSQL, MySQL, and MongoDB
I’d love your suggestions and advice 🙂

Читать полностью…

PostgreSQL

PostgreSQL Person of the Week interview with: Philippe Noël

https://postgresql.life/post/philippe_noel/

Читать полностью…

PostgreSQL

I'm looking for recorded video classes

Читать полностью…

PostgreSQL

Hii anybody have postgreSQL DBA classes please share

Читать полностью…

PostgreSQL

I am looking for postgres consultant/freelancer.

Who can help us to setup infrastructure and configuration for our saas application

Читать полностью…

PostgreSQL

They all should be able to. You could check out Nagios, Icinga2, CheckMK, ...

Читать полностью…

PostgreSQL

Ah ok, this explains stuff i experienced in the wild

Читать полностью…

PostgreSQL

You can't pg_dump newer PG versions. So dump using 16 and just try to feed it into your 13 cluster. YMMV.

Читать полностью…

PostgreSQL

-bash-4.2$ pg_restore -h 10.10.10.20 -U postgres -p 5432 -d dbtest /var/lib/pgsql/backup/dbtest2.sql
pg_restore: error: unsupported version (1.15) in file header
-bash-4.2$

Читать полностью…

PostgreSQL

Might require some editing of the resulting sql

Читать полностью…

PostgreSQL

Hi team ,
It's possible to restoration data that backup from postgres 16 and restore into postgres 13?

Читать полностью…

PostgreSQL

Hi everyone l would like to change my path from postgreSQL DBA to aws I have a 2 years of experience in postgreSQL DBA. Is it good to learn AWS. If it is good then Suggest me the best you tube channel to learn
#AWS

Читать полностью…

PostgreSQL

Paste there the trigger let's check

Читать полностью…

PostgreSQL

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.PostgreSQL.html

Читать полностью…

PostgreSQL

Can you describe your problem in more detail?

Читать полностью…

PostgreSQL

Error in postgresql while import file please help

Читать полностью…

PostgreSQL

I have azure devops ,mern stack ,power bi and dotnet net classes recordings

Читать полностью…

PostgreSQL

https://www.postgresqltutorial.com/postgresql-tutorial/

Читать полностью…

PostgreSQL

Mern Stack videos in 800

Читать полностью…

PostgreSQL

I did this work long time ago, it's not simple. Some DDL commands can be changed between versions of postgresql.
For example I met an issue with sequence defenition when AS INTEGER/BIGINT was added between versions into DDL command generated by pg_dump.
But it's possible to apply newest dump to oldest version of postgresql in some cases.
Patience, manual fixing dump and dump can be applied.

Читать полностью…

PostgreSQL

What monitor and alert tool are you using?
Does anyone have a tool that can monitor postgres + mysql?

Читать полностью…

PostgreSQL

So, pg_dump only works with the same version of cluster as the binary?

Читать полностью…

PostgreSQL

i got this error: pg_restore: error: unsupported version (1.15) in file header

Читать полностью…

PostgreSQL

(perhaps use the older binaries to export the db?)

Читать полностью…

PostgreSQL

Assuming you never used any of the newest functions of postgresql 16, you should he able to pg_dump and pg_restore in textual (SQL) form

Читать полностью…

PostgreSQL

Is anyone from Russia?

Читать полностью…

PostgreSQL

i forget to write the parameter -C

Читать полностью…
Subscribe to a channel