How do we use classes as types?
От | Oliver Elphick |
---|---|
Тема | How do we use classes as types? |
Дата | |
Msg-id | 200012302032.eBUKWKH19890@linda.lfix.co.uk обсуждение исходный текст |
Ответы |
Re: How do we use classes as types?
|
Список | pgsql-general |
It is possible to use a class as an attribute of another class: bray=# create table junk (id serial PRIMARY KEY, dt DATE NOT NULL); NOTICE: CREATE TABLE will create implicit sequence 'junk_id_seq' for SERIAL column 'junk.id' NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index 'junk_pkey' for table 'junk' CREATE bray=# create table junk1 (j junk, descrip text); CREATE But I cannot find any documentation on how to insert a row into junk1. Nothing I have tried works: bray=# insert into junk1 values (null, current_date, 'this is text'); ERROR: Attribute 'j' is of type 'junk' but expression is of type 'unknown' You will need to rewrite or cast the expression bray=# insert into junk1 values ((null, current_date), 'this is text'); ERROR: parser: parse error at or near "," bray=# insert into junk1 values ((null, current_date)::junk, 'this is text'); ERROR: parser: parse error at or near "::" bray=# insert into junk1 (j.dt, descrip) values ( current_date, 'this is text'); ERROR: parser: parse error at or near "." etc... Does anyone know how to get rows into such a table? -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47 GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "Give to him that asketh thee, and from him that would borrow of thee turn not away." Matthew 5:42
В списке pgsql-general по дате отправления: