Re: postgresql varchar[] data type equivalent in Oracle - Mailing list pgsql-general

From Albe Laurenz
Subject Re: postgresql varchar[] data type equivalent in Oracle
Date
Msg-id AFCCBB403D7E7A4581E48F20AF3E5DB2038778E8@EXADV1.host.magwien.gv.at
Whole thread Raw
In response to postgresql varchar[] data type equivalent in Oracle  ("Murali Doss" <Murali.Doss@mphasis.com>)
List pgsql-general
Murali Doss wrote:
>
> I like to know about postgresql varchar[ ] data type
> equivalent in Oracle.

The best I can think of is a VARRAY, though you cannot access
it by index in SQL (you need a stored procedure or client API
for that). Quite clumsy.

Example:

SQL> CREATE TYPE VARCHAR_A AS VARRAY(100) OF VARCHAR2(10);
  2  /

Type created.

SQL> CREATE TABLE N(ID NUMBER(10,0) PRIMARY KEY, A VARCHAR_A);

Table created.

SQL> INSERT INTO N VALUES (1, VARCHAR_A('one', 'two', 'three'));

1 row created.

SQL> SELECT A FROM N WHERE ID=1;

A
------------------------------------------------------------------------
--------
VARCHAR_A('one', 'two', 'three')

SQL> SELECT X.* FROM N, TABLE(N.A) X WHERE ID=1;

COLUMN_VALUE
----------------------------------------
one
two
three


Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: problem importing data with psql
Next
From: "Albe Laurenz"
Date:
Subject: Re: Rule vs Trigger