Re: [GENERAL] Composite type

2014-02-03 Thread George Ant
Chris, thank you for your time. Your reply was really helpful! I followed your advice. I didn't sacrifice relational design (I didn't have this intention) and I used joins/views. Kind Regards, George Antonopoulos -- View this message in context: http://postgresql.1045698.n5.nabble.com/Compos

Re: [GENERAL] Composite type

2014-01-30 Thread Chris Travers
On Wed, Jan 29, 2014 at 1:44 PM, George Ant wrote: > Guys thank you for your replies, you really helped me a lot!!! > > I haven't use Postgres before and its the first time I am "playing" with > composite types, so sorry if I hurted your eyes with my question! > > Kevin I followed your suggestion

Re: [GENERAL] Composite type

2014-01-30 Thread George Ant
Guys thank you for your replies, you really helped me a lot!!! I haven't use Postgres before and its the first time I am "playing" with composite types, so sorry if I hurted your eyes with my question! Kevin I followed your suggestion and seems to work fine.I think it is what I was looking for.

Re: [GENERAL] Composite type

2014-01-28 Thread Chris Travers
As a note, the following also works: CREATE TYPE foo AS (bar text, baz int); CREATE TABLE table_of_foo OF foo (primary key(bar)); The one thing that doesn't work is the REF syntax and the operators that go along with that. However, you could come up with dereferencing functions and operators one

Re: [GENERAL] Composite type

2014-01-28 Thread Kevin Grittner
antono124 wrote: > Lets say that we have 2 tables. > Create Table "table1" Of "type1" > Create Table "table2" Of "type2" > > I want to refer the first table in the second. I want to > reference the whole table not only one field, so something like > that: > > CREATE TYPE type2 AS OBJECT ( >   va

Re: [GENERAL] Composite type

2014-01-27 Thread John R Pierce
On 1/26/2014 9:02 AM, antono124 wrote: I want to refer the first table in the second. I want to reference the whole table not only one field, so something like that: does this table1 have a primary key? if so, referencing the PK allows you to fetch the whole row via a join. if this table do

Re: [GENERAL] Composite type

2014-01-27 Thread Michael Paquier
On Mon, Jan 27, 2014 at 2:02 AM, antono124 wrote: > Lets say that we have 2 tables. > Create Table "table1" Of "type1" > Create Table "table2" Of "type2" > > I want to refer the first table in the second. I want to reference the whole > table not only one field, so something like that: > > CREATE

Re: [GENERAL] composite type use in pl/gpsql

2012-06-13 Thread Merlin Moncure
On Wed, Jun 13, 2012 at 12:25 PM, Little, Douglas wrote: > Hello, > > Thanks in advance for taking my question. > > Running on Greenplum 4.1.2/ based on PG 8.2.3 kernal > > > > We make extensive use of functions to do our ETL. > > So, I’m building a stored procedure template for our developers. >

Re: [GENERAL] Composite Type : pros and cons

2012-01-26 Thread Merlin Moncure
On Thu, Jan 26, 2012 at 3:22 AM, Leguevaques Alex wrote: > > Hello, > I'm new to Pg and exploring its advanced functionalities for a project. > I find composite type very interesting, but what are problems/limitations ? > I'd want to create this structure for example: Composite types add a little

Re: [GENERAL] Composite type, DEFAULT, NOT NULL, REFERENCES

2011-10-19 Thread Merlin Moncure
On Wed, Oct 19, 2011 at 9:32 AM, erhaminus wrote: > > Hi, > > Is a way to define DEFAULT, NOT NULL and REFERENCES for members of composite > type? > > For example: > > -- type > CREATE TYPE bibl.bibliography AS > ( >        edition TEXT, >        publisher_id BIGINT > ); > > -- table def > create

Re: [GENERAL] Composite type, DEFAULT, NOT NULL, REFERENCES

2011-10-19 Thread David Johnston
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of erhaminus Sent: Wednesday, October 19, 2011 10:33 AM To: pgsql-general@postgresql.org Subject: [GENERAL] Composite type, DEFAULT, NOT NULL, REFERENCES Hi, Is a way to def

Re: [GENERAL] Composite type operator not unique

2010-10-06 Thread Trigve
On 6. Okt, 08:48 h., Trigve wrote: > Hi, > I'm trying to make a custom composite type and use it as a PK and FK. > When adding FK to table I've got trhis error: operator is not unique: > "BigintRef" pg_catalog.= "BigintRef" (see below). Here is my type > definition with operator: > > CREATE TYPE "

Re: [GENERAL] Composite type operator not unique

2010-10-06 Thread Merlin Moncure
On Wed, Oct 6, 2010 at 2:48 AM, Trigve wrote: > Hi, > I'm trying to make a custom composite type and use it as a PK and FK. > When adding FK to table I've got trhis error: operator is not unique: > "BigintRef" pg_catalog.= "BigintRef" (see below). Here is my type > definition with operator: > > CR

Re: [GENERAL] composite type and domain

2009-05-29 Thread Scott Bailey
Grzegorz Jaśkiewicz wrote: On Fri, May 29, 2009 at 3:37 AM, Scott Bailey wrote: Did you read the article I sent you earlier? Well, the difference here is that this way db doesn't really check anything :) you just choose path of execution, that you created prior. That's cheating :p So yes, I

Re: [GENERAL] composite type and domain

2009-05-29 Thread Grzegorz Jaśkiewicz
On Fri, May 29, 2009 at 3:37 AM, Scott Bailey wrote: > Did you read the article I sent you earlier? Well, the difference here is that this way db doesn't really check anything :) you just choose path of execution, that you created prior. That's cheating :p So yes, I read that article, but that's

Re: [GENERAL] composite type and domain

2009-05-28 Thread Scott Bailey
Grzegorz Jaśkiewicz wrote: 2009/5/27 Scott Bailey : Who said anything about the application level? can you give an example please ? Did you read the article I sent you earlier? I'm doing almost the exact same thing you are doing save the bytea field. I create a timespan composite type t

Re: [GENERAL] composite type and domain

2009-05-28 Thread Grzegorz Jaśkiewicz
2009/5/27 Scott Bailey : > Who said anything about the application level? can you give an example please ? -- GJ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] composite type and domain

2009-05-27 Thread Scott Bailey
Grzegorz Jaśkiewicz wrote: well, I need database to guard data, not application. Application can check things too, but database's job is to make sure data is integral. Who said anything about the application level? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make

Re: [GENERAL] composite type and domain

2009-05-27 Thread Grzegorz Jaśkiewicz
well, I need database to guard data, not application. Application can check things too, but database's job is to make sure data is integral. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] composite type and domain

2009-05-27 Thread Scott Bailey
Scott Bailey wrote: Grzegorz Jaśkiewicz wrote: Why is it not possible to create domain on composite type ? Consider the example, I got (a bytea, b timestamp, c timestamp). Where b < c always, and both b and c have some default value, a can stay null. Now, I don't want to go berserk, and create

Re: [GENERAL] composite type and domain

2009-05-27 Thread Scott Bailey
Grzegorz Jaśkiewicz wrote: Why is it not possible to create domain on composite type ? Consider the example, I got (a bytea, b timestamp, c timestamp). Where b < c always, and both b and c have some default value, a can stay null. Now, I don't want to go berserk, and create aditional table for t

Re: [GENERAL] composite type and domain

2009-05-27 Thread Grzegorz Jaśkiewicz
When I start to complain about domains and types in postgresql, people often ask me - so what's exactly wrong with it - well, here you go. I am trying to provide some feedback ;) -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www

Re: [GENERAL] composite type and domain

2009-05-27 Thread Merlin Moncure
2009/5/25 Grzegorz Jaśkiewicz : > Why is it not possible to create domain on composite type ? > > Consider the example, I got (a bytea, b timestamp, c timestamp). Where > b < c always, and both b and c have some default value, a can stay > null. > Now, I don't want to go berserk, and create adition

Re: [GENERAL] Composite type evaluates to Null if any element is null

2008-12-17 Thread Merlin Moncure
On Wed, Dec 17, 2008 at 12:23 PM, Andrew Gould wrote: > What are composite types used for? Do they allow you to search multiple > fields for a value more easily? A number of things really. Starting with 8.4, they can be used with indexes and comparisons. so the list is growing. The main utilit

Re: [GENERAL] Composite type evaluates to Null if any element is null

2008-12-17 Thread Andrew Gould
What are composite types used for? Do they allow you to search multiple fields for a value more easily? Thanks, Andrew

Re: [GENERAL] Composite type evaluates to Null if any element is null

2008-12-17 Thread Merlin Moncure
On Wed, Dec 17, 2008 at 11:09 AM, Ketema Harris wrote: > I have just re-read chapter 8.15 of the 8.3 manual and I am understanding > why a composite type would evaluate to NUll if any of it elements are null. > > Can anyone explain this behavior? To me if I have a composite type column > and ther

Re: [GENERAL] composite type array and index

2007-05-24 Thread Merlin Moncure
On 5/24/07, Marek Lewczuk <[EMAIL PROTECTED]> wrote: Hello everyone, it's great to have in next release (8.3) great feature: composite type array. I'm waiting to see how it works, however I wonder whether it will be possible to create an index on a column of composite type array just like we have

Re: [GENERAL] composite type insert

2006-11-19 Thread Ron Peterson
On Sun, Nov 19, 2006 at 02:09:11AM -0500, Tom Lane wrote: > Ron Peterson <[EMAIL PROTECTED]> writes: > > How should I create a composite type value out of columns a and b in > > table tt that I can insert into table atable? > > Hm, it works for me with an explicit cast: > > INSERT INTO > atable

Re: [GENERAL] composite type insert

2006-11-18 Thread Tom Lane
Ron Peterson <[EMAIL PROTECTED]> writes: > How should I create a composite type value out of columns a and b in > table tt that I can insert into table atable? Hm, it works for me with an explicit cast: INSERT INTO atable SELECT ROW(a, b)::atype FROM tt; Perhaps we should allow this in an

Re: [GENERAL] Composite type within a composite type?

2005-07-18 Thread Tom Lane
Juan Miguel Paredes <[EMAIL PROTECTED]> writes: > DECLARE > res helpdesk.tp_res_conestadosdisponiblessoporte; > BEGIN > IF estadoactual = 'Abierto' THEN > SELECT INTO res.filas * > FROM tbl_estadosoporte Without having looked at the code, I suspect that plpgsql just assumes res.filas

Re: [GENERAL] Composite type versus Domain constraints.

2005-04-13 Thread James Robinson
On Apr 13, 2005, at 11:50 AM, Tom Lane wrote: Thank you for the great info. If I may, here's another question. I am in the need of new scalar types, essentially domain'd smallints, hence why my composite type had but one composite member. Domain'd smallints would be great, but it seems when they g

Re: [GENERAL] Composite type versus Domain constraints.

2005-04-13 Thread Tom Lane
James Robinson <[EMAIL PROTECTED]> writes: > Thank you for the great info. If I may, here's another question. I am in > the need of new scalar types, essentially domain'd smallints, hence > why my composite type had but one composite member. Domain'd > smallints would be great, but it seems when th

Re: [GENERAL] Composite type versus Domain constraints.

2005-04-13 Thread James Robinson
On Apr 12, 2005, at 4:48 PM, Tom Lane wrote: James Robinson <[EMAIL PROTECTED]> writes: insert into simple_table values (null, '(43)'); -- GRR works!!! It'll let any smallint in. What happened to the constraint? The composite-type input routine doesn't check any constraints ... and that includes do

Re: [GENERAL] Composite type versus Domain constraints.

2005-04-12 Thread Tom Lane
James Robinson <[EMAIL PROTECTED]> writes: > insert into simple_table values (null, '(43)'); -- GRR works!!! It'll > let any smallint in. What happened to the constraint? The composite-type input routine doesn't check any constraints ... and that includes domains. You can make it work if you don

Re: [GENERAL] Composite Type Argument Construction to a Function

2004-09-29 Thread Tom Lane
<[EMAIL PROTECTED]> writes: > My question is - HOW do I construct the argument to > my_function(my_type) so that the function recognises that I am passing > into it composite data? Sorry, don't think you're going to have much joy on that in 7.3. In 8.0 you could do it with a ROW() constructor, bu

Re: [GENERAL] composite type and assignment in plpgsql

2004-04-27 Thread Ron St-Pierre
Ivan Sergio Borgonovo wrote: On Tue, 27 Apr 2004 10:12:13 -0700 thisSession := ( ''t'', md5( now( ) || rand( ) ) ); - md5 takes TEXT as an argument, not a numeric type Since it works you surely fixed my code but this should't be an issue since I tried test1=# select md5( now( ) || r

Re: [GENERAL] composite type and assignment in plpgsql

2004-04-27 Thread Ivan Sergio Borgonovo
On Tue, 27 Apr 2004 10:12:13 -0700 Ron St-Pierre <[EMAIL PROTECTED]> wrote: > Ivan Sergio Borgonovo wrote: > > --HERE!!! > > thisSession := ( ''t'', md5( now( ) || rand( ) ) ); > > > - md5 takes TEXT as an argument, not a numeric type Since it works you surely fixed my code but this shou

Re: [GENERAL] composite type and assignment in plpgsql

2004-04-27 Thread Ron St-Pierre
Ron St-Pierre wrote: Ivan Sergio Borgonovo wrote: what's wrong with this? create type tSession as ( ty_found boolean, ty_Session char(32) ); create or replace function GetSessionID( integer ) returns tSession as ' declare thisSession tSession; begin --HERE!!! thisSession := ( ''

Re: [GENERAL] composite type and assignment in plpgsql

2004-04-27 Thread Ron St-Pierre
Ivan Sergio Borgonovo wrote: what's wrong with this? create type tSession as ( ty_found boolean, ty_Session char(32) ); create or replace function GetSessionID( integer ) returns tSession as ' declare thisSession tSession; begin --HERE!!! thisSession := ( ''t