BUG #7907: BEFORE DELETE TRIGGER (not instead of, my trigger BEFORE)not row delete...

From: ibrahimkocaoglutr(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #7907: BEFORE DELETE TRIGGER (not instead of, my trigger BEFORE)not row delete...
Date: 2013-02-26 08:30:05
Message-ID: E1UAFvJ-0000LF-9h@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 7907
Logged by: İBRAHIM KOCAOGLU
Email address: ibrahimkocaoglutr(at)gmail(dot)com
PostgreSQL version: 9.1.0
Operating system: debian-6.stable
Description:

-- Function: f_is_isletme_sayim_hazirlik_delete()

-- DROP FUNCTION f_is_isletme_sayim_hazirlik_delete();

CREATE OR REPLACE FUNCTION f_is_isletme_sayim_hazirlik_delete()
RETURNS trigger AS
$BODY$ BEGIN

INSERT INTO log_isletme_sayim_hazirlik (sayim_hazirlik_no, isletme_no,
urun_no, barkod,
sayilan_miktar, sayim_baslangic_saati, sayim_baslangic_tarihi,
son_sayim_saati,
son_sayim_tarihi, son_kypk, log_nedeni)
VALUES (old.sayim_hazirlik_no, old.isletme_no, old.urun_no, old.barkod,
old.sayilan_miktar,
old.sayim_baslangic_saati, old.sayim_baslangic_tarihi, old.son_sayim_saati,
old.son_sayim_tarihi,
old.son_kypk, 'KAYIT SİLME'::character varying);

RETURN NEW;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION f_is_isletme_sayim_hazirlik_delete()
OWNER TO postgres;
-- Function: f_is_isletme_sayim_hazirlik_insert()

-- DROP FUNCTION f_is_isletme_sayim_hazirlik_insert();

CREATE OR REPLACE FUNCTION f_is_isletme_sayim_hazirlik_insert()
RETURNS trigger AS
$BODY$ BEGIN

INSERT INTO log_isletme_sayim_hazirlik (sayim_hazirlik_no, isletme_no,
urun_no, barkod, sayilan_miktar, sayim_baslangic_saati,
sayim_baslangic_tarihi, son_sayim_saati, son_sayim_tarihi, son_kypk,
log_nedeni)
VALUES ( new.sayim_hazirlik_no, new.isletme_no, new.urun_no, new.barkod,
new.sayilan_miktar, new.sayim_baslangic_saati,
new.sayim_baslangic_tarihi, new.son_sayim_saati, new.son_sayim_tarihi,
new.son_kypk, 'YENİ KAYIT'::character varying);


RETURN NEW;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION f_is_isletme_sayim_hazirlik_insert()
OWNER TO postgres;

-- Function: f_is_isletme_sayim_hazirlik_update()

-- DROP FUNCTION f_is_isletme_sayim_hazirlik_update();

CREATE OR REPLACE FUNCTION f_is_isletme_sayim_hazirlik_update()
RETURNS trigger AS
$BODY$ BEGIN

INSERT INTO log_isletme_sayim_hazirlik (sayim_hazirlik_no, isletme_no,
urun_no, barkod, sayilan_miktar,
sayim_baslangic_saati, sayim_baslangic_tarihi, son_sayim_saati,
son_sayim_tarihi, son_kypk, log_nedeni)
VALUES (new.sayim_hazirlik_no, new.isletme_no, new.urun_no, new.barkod,
new.sayilan_miktar,
new.sayim_baslangic_saati, new.sayim_baslangic_tarihi, new.son_sayim_saati,
new.son_sayim_tarihi, new.son_kypk, 'KAYIT GÜNCELLEME'::character varying);

RETURN NEW;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION f_is_isletme_sayim_hazirlik_update()
OWNER TO postgres;

-- Table: isletme_sayim_hazirlik

-- DROP TABLE isletme_sayim_hazirlik;

CREATE TABLE isletme_sayim_hazirlik
(
sayim_hazirlik_no bigserial NOT NULL,
isletme_no smallint NOT NULL,
urun_no bigint NOT NULL,
barkod character varying(98) NOT NULL,
sayilan_miktar numeric(19,3) NOT NULL,
sayim_baslangic_saati time with time zone NOT NULL,
sayim_baslangic_tarihi date NOT NULL,
son_sayim_saati time with time zone NOT NULL,
son_sayim_tarihi date NOT NULL,
son_kypk character varying(20) NOT NULL,
CONSTRAINT pkx_isletme_sayim_hazirlik PRİMARY KEY (sayim_hazirlik_no ,
isletme_no )
)
WITH (
OIDS=FALSE
);
ALTER TABLE isletme_sayim_hazirlik
OWNER TO postgres;

-- Table: log_isletme_sayim_hazirlik

-- DROP TABLE log_isletme_sayim_hazirlik;

CREATE TABLE log_isletme_sayim_hazirlik
(
log_sayim_hazirlik_no bigserial NOT NULL,
sayim_hazirlik_no bigint NOT NULL,
isletme_no smallint NOT NULL,
urun_no bigint NOT NULL,
barkod character varying(98) NOT NULL,
sayilan_miktar numeric(19,3) NOT NULL,
sayim_baslangic_saati time with time zone NOT NULL,
sayim_baslangic_tarihi date NOT NULL,
son_sayim_saati time with time zone NOT NULL,
son_sayim_tarihi date NOT NULL,
son_kypk character varying(20) NOT NULL,
log_saati time with time zone NOT NULL DEFAULT ('now'::text)::time with
time zone,
log_tarihi date NOT NULL DEFAULT ('now'::text)::date,
log_kypk character varying(20) NOT NULL DEFAULT "current_user"(),
log_nedeni character varying(20) NOT NULL,
CONSTRAINT pkx_log_isletme_sayim_hazirlik PRİMARY KEY
(log_sayim_hazirlik_no , isletme_no )
)
WITH (
OIDS=FALSE
);
ALTER TABLE log_isletme_sayim_hazirlik
OWNER TO postgres;

-- Trigger: trg_f_is_isletme_sayim_hazirlik_delete on
isletme_sayim_hazirlik

-- DROP TRIGGER trg_f_is_isletme_sayim_hazirlik_delete ON
isletme_sayim_hazirlik;

CREATE TRIGGER trg_f_is_isletme_sayim_hazirlik_delete
BEFORE DELETE
ON isletme_sayim_hazirlik
FOR EACH ROW
EXECUTE PROCEDURE f_is_isletme_sayim_hazirlik_delete();

-- Trigger: trg_f_is_isletme_sayim_hazirlik_insert on
isletme_sayim_hazirlik

-- DROP TRIGGER trg_f_is_isletme_sayim_hazirlik_insert ON
isletme_sayim_hazirlik;

CREATE TRIGGER trg_f_is_isletme_sayim_hazirlik_insert
BEFORE INSERT
ON isletme_sayim_hazirlik
FOR EACH ROW
EXECUTE PROCEDURE f_is_isletme_sayim_hazirlik_insert();

-- Trigger: trg_f_is_isletme_sayim_hazirlik_update on
isletme_sayim_hazirlik

-- DROP TRIGGER trg_f_is_isletme_sayim_hazirlik_update ON
isletme_sayim_hazirlik;

CREATE TRIGGER trg_f_is_isletme_sayim_hazirlik_update
BEFORE UPDATE
ON isletme_sayim_hazirlik
FOR EACH ROW
EXECUTE PROCEDURE f_is_isletme_sayim_hazirlik_update();

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Janes 2013-02-26 16:41:19 Re: BUG #7902: lazy cleanup of extraneous WAL files can cause out of disk issues
Previous Message adam.tomjack 2013-02-26 00:59:28 BUG #7906: pg_dump exits successfully after an error