converting Sybase RULE -> postgreSQL

From: Charles Hauser <chauser(at)duke(dot)edu>
To: PSQL_list <pgsql-sql(at)postgresql(dot)org>
Subject: converting Sybase RULE -> postgreSQL
Date: 2002-09-30 17:02:45
Message-ID: 1033405365.19271.39.camel@pandorina.biology.duke.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I am still a novice at this so bear with me.
I am going to try to alter a Sybase TABLE create script (excerpt
below)to postgreSQL.

I suspect some of the script is specific to Sybase and I'll just need to
remove it. In particular there are numerous stored procedures ("sp_").
But first things first.

RULES:

In the sample below the RULE CloneEnd_type restricts input: the only
data which can be inserted or updated into CloneEnd.type have to be one
of 'BAC_end', 'YAC_end' etc..

I know postgresql supports RULES but have not used them prior. How would
one cone this for postgresql?

Stored Procedures:

Are FUNCTIONS (postgresql)equivalent to stored procedures (Sybase)?

### Sybase code: ###

CREATE RULE CloneEnd_type_rule
AS @col IN ('BAC_end', 'YAC_end', 'TAC_end', 'EST', 'unknown', 'P1_end', 'plasmid')
go

ALTER TABLE CloneEnd
ADD PRIMARY KEY (clone_end_id)
go

exec sp_primarykey CloneEnd,
clone_end_id
go

exec sp_bindrule CloneEnd_type_rule, 'CloneEnd.type'
exec sp_bindefault Set_To_Current_Date, 'CloneEnd.date_last_modified'
exec sp_bindefault Set_to_False, 'CloneEnd.is_obsolete'
go

regards,

Charles

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mike Sosteric 2002-09-30 17:04:48 Re: [GENERAL] arrays
Previous Message Josh Berkus 2002-09-30 16:30:33 Re: [GENERAL] arrays