Re: [SQL] Unique index and unique constraint

2013-07-26 Thread Luca Vernini
I try to explain my point of view, also in my not so good English: A primary key is defined by dr. Codd in relational model. The key is used to identify a record. In good practice, you must always define a primary key. Always. The unique constraint will simply say: this value (or combination) shou

Re: [SQL] Update a composite nested type variable

2013-07-08 Thread Luca Vernini
2013/7/8 David Johnston > > This may be a pl/pgsql limitation but you should probably provide a > complete > self-contained example with your attempt so that user-error can be > eliminated. > > David J. > > All right. Here you are a complete example. Just tested it. Sorry for the long email. CR

[SQL] Update a composite nested type variable

2013-07-08 Thread Luca Vernini
I'm writing a system with havy use of composite types. I have a doubt. I'm writing all in functions with language plpgsql. When I read a field from a composite type I must write something like this: status = ((in_customer.customer_data).customer_status).status_id And this works fine. I need to en

Re: [SQL] Select clause in JOIN statement

2013-06-13 Thread Luca Vernini
It works. Also consider views. Just used this on a my db: SELECT * FROM tblcus_customer INNER JOIN ( SELECT * FROM tblcus_customer_status WHERE status_id > 0) AS b ON tblcus_customer.status = b.status_id You can even join with a function result. Regards, Luca. 2013/6/14 JORGE MALDONADO : > I