X-Original-To: pgsql-interfaces-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 9EB8B9FA501 for ; Thu, 29 Jun 2006 09:38:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 89088-01 for ; Thu, 29 Jun 2006 09:38:08 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.zanthus.com.br (mail.zanthus.com.br [200.212.65.85]) by postgresql.org (Postfix) with ESMTP id 2955B9FA081 for ; Thu, 29 Jun 2006 09:38:06 -0300 (ADT) Received: from cprsakai ([192.168.0.71]) by mail.zanthus.com.br (8.13.4/8.13.4/Debian-3) with ESMTP id k5TCfimu024261; Thu, 29 Jun 2006 09:41:44 -0300 Reply-To: From: "Rodrigo Sakai" To: "'Tom Lane'" Cc: Subject: RES: Creating a new type Date: Thu, 29 Jun 2006 09:38:17 -0300 Message-ID: <000001c69b78$e5cfcee0$4700a8c0@TREEZANTHUS> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01C69B5F.C08296E0" X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcaaxBOdFOYJYFYKS96vI3iaoyz6EAAsY0wg In-Reply-To: <15256.1151506785@sss.pgh.pa.us> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 X-Zanthus-MailScanner: Found to be clean X-Zanthus-MailScanner-From: rodrigo.sakai@zanthus.com.br X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/45 X-Sequence-Number: 6186 This is a multi-part message in MIME format. ------=_NextPart_000_0001_01C69B5F.C08296E0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Ok, let me explain better! In my table example I will store datas like Emp_id emp_name salary emp_time 1 Rodrigo 1,200.00 (2006-jan-01, 2006-jun-01) 1 Rodrigo 2,100.00 (2006-mar-01, 2006-sep-01) Considering the overlaps of emp_time and this question: what is the salary of employee Rodrigo on 2006-apr-01 ??? This data is inconsistent because the overlaps of time! So, I have to guarantee that this situation doesn't occur! But I don't want to use triggers because this check must be done on almost all tables that uses the type: CREATE TYPE time_interval ( Tbegin date, Tend date ) And be easy to the user. For example, any table that is created using this type garantees that the overlaps will not occur! To do this I have to get access for the past data of the table, and so, I have to know wich table is using the type and have data being inserted! Is that a way of doing this? -----Mensagem original----- De: pgsql-interfaces-owner@postgresql.org [mailto:pgsql-interfaces-owner@postgresql.org] Em nome de Tom Lane Enviada em: quarta-feira, 28 de junho de 2006 12:00 Para: rodrigo.sakai@zanthus.com.br Cc: pgsql-interfaces@postgresql.org Assunto: Re: [INTERFACES] Creating a new type "Rodrigo Sakai" writes: > So, when I execute an INSERT operation on this table, the functions that > deals with this type need the id or name of the table that the data was > inserted! Why? Your example datatype doesn't seem to require any such thing. > How can I get this ID or NAME inside this functions??? You can't. The question itself is bogus because it assumes that data values only exist within tables. You could not have a transient value of the datatype (eg, a function result) because that is not stored in any table. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org ------=_NextPart_000_0001_01C69B5F.C08296E0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

  Ok, let me explain better! In my table = example I will store datas like

 

 

Emp_id

emp_name

salary

emp_time

1

Rodrigo

1,200.00

(2006-jan-01, = 2006-jun-01)

1

Rodrigo

2,100.00

(2006-mar-01, = 2006-sep-01)

 

 

  Considering the overlaps of emp_time = and this question: what is the salary of employee Rodrigo on 2006-apr-01 ??? This = data is inconsistent because the overlaps of = time!

 

  So, I have to guarantee that this = situation doesn’t occur! But I don’t want to use triggers because this = check must be done on almost all tables that uses the = type:

 

CREATE TYPE time_interval = (

    Tbegin = date,

    Tend = date

   )

 

 And be easy to the user. For example, = any table that is created using this type garantees that the overlaps will not = occur! To do this I have to get access for the past data of the table, and so, I = have to know wich table is using the type and have data being = inserted!

 

  Is that a way of doing = this?

 

 

-----Mensagem original-----
De: pgsql-interfaces-owner@postgresql.org = [mailto:pgsql-interfaces-owner@postgresql.org] Em nome
de Tom = Lane
Enviada em: quarta-feira, 28 de junho de 2006 12:00
Para: rodrigo.sakai@zanthus.com.br
Cc: pgsql-interfaces@postgresql.org
Assunto: Re: [INTERFACES] Creating a new type

 

"Rodrigo Sakai" <rodrigo.sakai@zanthus.com.br> = writes:

>   So, when I execute an INSERT operation on this = table, the functions that

> deals with this type need the id or name of the table that = the data was

> inserted!

 

Why?  Your example datatype doesn't seem to require any = such thing.

 

>   How can I get this ID or NAME inside this = functions???

 

You can't.  The question itself is bogus because it assumes = that data

values only exist within tables.  You could not have a = transient value

of the datatype (eg, a function result) because that is not = stored in

any table.

 

           = ;       regards, tom lane

 

---------------------------(end of broadcast)---------------------------

TIP 4: Have you searched our list = archives?

 

           = ;    http://archives.postgresql.org

------=_NextPart_000_0001_01C69B5F.C08296E0--