Postgresql FK to MS SQL triggers

From: "Igor Kryltsov" <kryltsov(at)yahoo(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Postgresql FK to MS SQL triggers
Date: 2005-02-28 05:46:55
Message-ID: cvub0o$1sll$2@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

If you are moving from Postgres to MS SQL you will most likely will find
that you can not recreate your PostgreSQL FK to MSSQL FK because this
enterprise class database will NOT allow you to create all 3 FK which are
exist in your PGSQL:

table users(user_id PK)

table journal(created_by, modified_by, deleted_by)

ADD CONSTRAINT fk_created_by FOREIGN KEY (created_by) REFERENCES
users(user_id) MATCH FULL ON UPDATE
CASCADE ON DELETE CASCADE;
ADD CONSTRAINT fk_modified_by FOREIGN KEY (modified_by) REFERENCES
users(user_id) MATCH FULL ON UPDATE
CASCADE ON DELETE CASCADE;
ADD CONSTRAINT fk_deleted_by FOREIGN KEY (deleted_by) REFERENCES
users(user_id) MATCH FULL ON UPDATE
CASCADE ON DELETE CASCADE;

For interested people I wrote a PHP script which:
1) Extracts all underlying triggers from pg_trigger table in Postgres used
to support FK (3 triggers for each FK)
2) Generates a MSSQL script file which recreates all triggers in MSSQL

Hope it will save some time for somebody.

Igor

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2005-02-28 09:12:09 Re: SQL error: function round(double precision, integer) does
Previous Message Michael Fuhr 2005-02-28 03:33:55 Re: AutoCommit and DDL