[SQL] Private functions

2010-03-13 Thread Gianvito Pio
Hi all, is there a way to write a function that can only be called by another function but not directly using SELECT function_name ( )? Thanks -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] Drop all constraints

2010-03-06 Thread Gianvito Pio
Hi all, is there a way to drop all constraints of a table? I found this workaround in the manual: CREATE TABLE temp AS SELECT * FROM distributors; DROP TABLE distributors; CREATE TABLE distributors AS SELECT * FROM temp; DROP TABLE temp; Is there any other way to do it? Thanks -- Sent via pgsq

[SQL] Check type compatibility

2010-03-06 Thread Gianvito Pio
Hi all, is there a way to check if two attribute are type compatible (for example integer and serial, integer and integer, character varying and text, etc..)? Example: IF (compatible (table1.att1, table2.att2)) THEN ... ELSE ... END IF; Thanks -- Sent via pgsql-sql mailing l

[SQL] Triggers on system tables

2010-03-03 Thread Gianvito Pio
Hi all, is there a way (also strange) to define a trigger on a system table (for example on pg_class)? I tried but I got (as expected) a permission denied message... Thanks

[SQL] Create functions using a function

2010-03-01 Thread Gianvito Pio
Hi all, is there a way to define functions and/or triggers in a function? For example, can I create a function that takes an argument and defines a function that has the name passed as argument to the first function? Something like this . CREATE FUNCTION test (name varchar) RETURNS VOID AS $

[SQL] Min and max element of an array column

2009-09-02 Thread Gianvito Pio
Hello, is it possible to obtain the minimum and the maximum single element of an array column? Example: [1, 2 ,5] [3, -1, 6] [9, 18,-4 ] I'd just like to make a query that gives me the min (-4) and the max(18) of the column. Is that possible without a function? Thanks -- Sent via pgsql-sql

[SQL] Table inheritance problem

2009-07-18 Thread Gianvito Pio
Hello, I have 3 tables: persons, operators and persons_position. This is a semplified examples of their structures: CREATE TABLE persons (id varchar NOT NULL, CONSTRAINT "PK_Persons" PRIMARY KEY(id)); CREATE TABLE operators (id varchar NOT NULL, CONSTRAINT "PK_Operators" PRIMARY KEY(id)) INHERI

[SQL] Timestamp with timezone with Default value

2009-07-18 Thread Gianvito Pio
Hi all, how can I define a column of timestamp with timezone type...with a default value? Thanks

Re: [SQL] Type inheritance

2009-06-06 Thread Gianvito Pio
: Re: [SQL] Type inheritance On 2009-06-06, Gianvito Pio wrote: --001485f44bfe3e357c046ba8b3d6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Oh that was just an example...Let me make a real example: I have a table "Sensors" (that has to contain different

Re: [SQL] Type inheritance

2009-06-06 Thread Gianvito Pio
5 Rob Sargent > I'm not sure how Temperature and Humidity are related as types beyond > "extends float". i.e. What tuple definition could alternatively have a Temp > or a Humidity value? (I do understand their physical relationship :) ) > > > > > Gianvito Pi

Re: [SQL] Type inheritance

2009-06-05 Thread Gianvito Pio
Domains just allow me to redefine base types, including some restrictions. I just want to define a my own type and then to define some new types that inherit from the first one. I hope it's clear now... 2009/6/5 Tom Lane > Gianvito Pio writes: > > I just want to ask you if it

[SQL] Type inheritance

2009-06-05 Thread Gianvito Pio
Hi all, I just want to ask you if it's possible to define sub types in PostgreSQL (Type inheritance). I found that table inheritance is possible...but I'd like to do it on types. Example: define a type Value and two subtypes Temperature and Humidity and then define a table that has an attribute of

[SQL] Methods declaration

2009-03-17 Thread Gianvito Pio
Hello, I've just started working with ordbms. I'm searching for differences between postgresql and oracle... Btw, I've found it's possible to declare a method for a specific type in oracle...so if I create a type MyType, I can associate it also a method MyMethodusing the costructors: CREATE T