[SQL] Alias to a type

2005-06-22 Thread Veikko Mäkinen
Hey, Is it possible to create a new type as an alias to a pre-defined type? I use USERID varchar(20) in almost every table I have I'd like to make an alias for that type eg. pseudo-sql create type myschema.useridtype as varchar(20); /pseudo-sql I might have to alter the type some day and

Re: [SQL] Alias to a type

2005-06-22 Thread Achilleus Mantzios
O Veikko Mδkinen έγραψε στις Jun 22, 2005 : Hey, Is it possible to create a new type as an alias to a pre-defined type? I use USERID varchar(20) in almost every table I have I'd like to make an alias for that type eg. pseudo-sql create type myschema.useridtype as varchar(20);

Re: [SQL] Alias to a type

2005-06-22 Thread Sean Davis
On Jun 22, 2005, at 7:42 AM, Achilleus Mantzios wrote: O Veikko Mδkinen έγραψε στις Jun 22, 2005 : Hey, Is it possible to create a new type as an alias to a pre-defined type? I use USERID varchar(20) in almost every table I have I'd like to make an alias for that type eg. pseudo-sql

Re: [SQL] Alias to a type

2005-06-22 Thread Bruno Wolff III
On Wed, Jun 22, 2005 at 08:04:39 -0400, Sean Davis [EMAIL PROTECTED] wrote: Just for my own edification, does creating a simple domain like this then require a whole set of functions for indexing, etc., like other more complex user-defined types, or will postgres do the right thing?

Re: [SQL] Alias to a type

2005-06-22 Thread Richard Huxton
Veikko Mäkinen wrote: Hey, Is it possible to create a new type as an alias to a pre-defined type? I use USERID varchar(20) in almost every table I have I'd like to make an alias for that type eg. CREATE DOMAIN username_string AS varchar(20); Test it with your client applications though,

Re: [SQL] Alias to a type

2005-06-22 Thread Achilleus Mantzios
O Sean Davis έγραψε στις Jun 22, 2005 : On Jun 22, 2005, at 7:42 AM, Achilleus Mantzios wrote: O Veikko MΞ΄kinen έγραψΡ στις Jun 22, 2005 : Hey, Is it possible to create a new type as an alias to a pre-defined type? I use USERID varchar(20) in almost every table I

Re: [SQL] Alias to a type

2005-06-22 Thread Veikko Mäkinen
Richard Huxton wrote: Veikko Mäkinen wrote: Hey, Is it possible to create a new type as an alias to a pre-defined type? I use USERID varchar(20) in almost every table I have I'd like to make an alias for that type eg. CREATE DOMAIN username_string AS varchar(20); Test it with your

Re: [SQL] Alias to a type

2005-06-22 Thread KÖPFERL Robert
Keep in mind, though. Using a DOMAIN in some definition 'seals' the domain. Yo can't change the domain unless you drop all dependent objects |-Original Message- |From: Veikko Mäkinen [mailto:[EMAIL PROTECTED] |Sent: Mittwoch, 22. Juni 2005 15:14 |To: pgsql-sql@postgresql.org |Subject: Re:

Re: [SQL] after delete trigger behavior

2005-06-22 Thread Stephan Szabo
On Wed, 22 Jun 2005, Russell Simpkins wrote: Hello, I have created a trigger function to update the sort_order column of a mapping table. I have table a that has a many to many relation ship with table b that is mapped as a_b where a_id, and b_id are the pk columns and there is a

Re: [SQL] after delete trigger behavior

2005-06-22 Thread Tom Lane
Stephan Szabo [EMAIL PROTECTED] writes: CREATE TRIGGER u_test1 BEFORE DELETE ON portfolio.test1 FOR EACH ROW EXECUTE PROCEDURE resort_test1(); I think this will work in an after delete trigger, but not in a before delete trigger (and seems to in my tests). I'm not sure what the spec says

Re: [SQL] after delete trigger behavior

2005-06-22 Thread Russell Simpkins
I suspect that if you read the spec carefully it would want a triggered data change violation error raised here. My advice is not to use a BEFORE trigger for this. What would you recommend then. I am using Hibernate in my java application and if the sort_order column (in this example

[SQL] encoding question

2005-06-22 Thread Joel Fradkin
Hi, I am trying to convert from SQL_ASCII to UNICODE. I have a program that will read from a table in one database and write to a table in a different database. I am hoping this all I need do (One data base is SQL_ASCII and the other is UNICODE). I get a byte sequence error

Re: [SQL] after delete trigger behavior

2005-06-22 Thread Tom Lane
Stephan Szabo [EMAIL PROTECTED] writes: Is there anything we have right now that will handle this kind of thing without requiring either updating all the counts after a deletion in a statement trigger or once per row updating all the counts for records with the same a (doing something like

Re: [SQL] after delete trigger behavior

2005-06-22 Thread Russell Simpkins
Actually, I had a larger script that did exactly what you propose. However I started to think that a profecient where clause would do the trick. In my mapping table, a and b are primary keys. a_id, b_id, c_sort_order. a_id is the parent and b_id is the child for my purposes, so if a_id is