Re: Inserting data in composite types

From: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
To: <rodrigo(dot)sakai(at)zanthus(dot)com(dot)br>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Inserting data in composite types
Date: 2006-11-13 15:11:53
Message-ID: 52EF20B2E3209443BC37736D00C3C1380B64BE22@EXADV1.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Hi, I have a question about how to insert data in composite types!
>
> CREATE TYPE t_time AS (
> a date,
> b date
> );
>
> CREATE TABLE salary (
> salary numeric(10,2),
> t_date t_time
> );
>
> I know that if I want to insert data in the table SALARY I
> just have to do like:
>
> INSERT INTO salary VALUES (1000.00, '(2006/10/10, 2006/12/10)');
>
> But if I have another table:
>
> CREATE TABLE employee (
> employee_id int,
> name varchar(30),
> emp_salary salary
> )
>
> How can I insert a single row in this table???

INSERT INTO employee VALUES (1, 'Albe', (10000.0, ('2006-01-01',
'2006-12-31')));

Yours,
Laurenz Albe

Browse pgsql-general by date

  From Date Subject
Next Message Chris Browne 2006-11-13 15:30:36 Re: Request for replication advice
Previous Message SunWuKung 2006-11-13 14:07:04 Re: chop off non-meaningful digits