Skip to main content
minor formating, add tag
Source Link
Erwin Brandstetter
  • 182.2k
  • 28
  • 457
  • 620

Postgresql PostgresSQL: Get single attribute of UDT in SELECT statement

I created a user-defined type in a PostgresqlPostgreSQL 9.2 database and am trying in the SELECT statement to get only an attribute of the UDT. However, I don't seem to get my code to work.

Creation of type and table:

CREATE TYPE ttp AS (f1 int, f2 int); CREATE TABLE tbl (ctyp ttp);

CREATE TYPE  ttp AS (f1 int, f2 int);
CREATE TABLE tbl (ctyp ttp);

The SELECT statement:

-- does not work
SELECT ctyp.f1 FROM tbl
SELECT ctyp(f1) FROM testtable

Both times I get an error. Is it possible to access a single attribute defined in a UDT in a SELECT?

Postgresql: Get single attribute of UDT in SELECT statement

I created a user-defined type in a Postgresql 9.2 database and am trying in the SELECT statement to get only an attribute of the UDT. However, I don't seem to get my code to work.

Creation of type and table:

CREATE TYPE ttp AS (f1 int, f2 int); CREATE TABLE tbl (ctyp ttp);

The SELECT statement:

-- does not work
SELECT ctyp.f1 FROM tbl
SELECT ctyp(f1) FROM testtable

Both times I get an error. Is it possible to access a single attribute defined in a UDT in a SELECT?

PostgresSQL: Get single attribute of UDT in SELECT statement

I created a user-defined type in a PostgreSQL 9.2 database and am trying in the SELECT statement to get only an attribute of the UDT. However, I don't seem to get my code to work.

Creation of type and table:

CREATE TYPE  ttp AS (f1 int, f2 int);
CREATE TABLE tbl (ctyp ttp);

The SELECT statement:

-- does not work
SELECT ctyp.f1 FROM tbl
SELECT ctyp(f1) FROM testtable

Both times I get an error. Is it possible to access a single attribute defined in a UDT in a SELECT?

deleted 3 characters in body; added 76 characters in body; edited title
Source Link
navige
  • 659
  • 1
  • 6
  • 9

Postgresql: Get single attribute of UDT in SELECT statement

I created a user-defined type in a Postgresql 9.2 database and am trying in the SELECT statement to get only an attribute of the UDT. However, I don't seem to get my code to work.

Creation of type and table:

CREATE TYPE ttp AS (f1 int, f2 int); CREATE TABLE tbl AS (ctyp ttp);

The SELECT statement:

-- does not work
SELECT ctyp.f1 FROM tbl
SELECT ctyp(f1) FROM testtable

Both times I get an error. Is it possible to access a single attribute defined in a UDT in a SELECT?

Postgresql: Get attribute of UDT in SELECT statement

I created a user-defined type in a Postgresql 9.2 database and am trying in the SELECT statement to get only an attribute of the UDT. However, I don't seem to get my code to work.

Creation of type and table:

CREATE TYPE ttp AS (f1 int, f2 int); CREATE TABLE tbl AS (ctyp ttp);

The SELECT statement:

-- does not work
SELECT ctyp.f1 FROM tbl
SELECT ctyp(f1) FROM testtable

Both times I get an error.

Postgresql: Get single attribute of UDT in SELECT statement

I created a user-defined type in a Postgresql 9.2 database and am trying in the SELECT statement to get only an attribute of the UDT. However, I don't seem to get my code to work.

Creation of type and table:

CREATE TYPE ttp AS (f1 int, f2 int); CREATE TABLE tbl (ctyp ttp);

The SELECT statement:

-- does not work
SELECT ctyp.f1 FROM tbl
SELECT ctyp(f1) FROM testtable

Both times I get an error. Is it possible to access a single attribute defined in a UDT in a SELECT?

Source Link
navige
  • 659
  • 1
  • 6
  • 9

Postgresql: Get attribute of UDT in SELECT statement

I created a user-defined type in a Postgresql 9.2 database and am trying in the SELECT statement to get only an attribute of the UDT. However, I don't seem to get my code to work.

Creation of type and table:

CREATE TYPE ttp AS (f1 int, f2 int); CREATE TABLE tbl AS (ctyp ttp);

The SELECT statement:

-- does not work
SELECT ctyp.f1 FROM tbl
SELECT ctyp(f1) FROM testtable

Both times I get an error.