Re: postgresql varchar[] data type equivalent in Oracle

From: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
To: "Murali Doss *EXTERN*" <Murali(dot)Doss(at)mphasis(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: postgresql varchar[] data type equivalent in Oracle
Date: 2007-06-26 09:08:36
Message-ID: AFCCBB403D7E7A4581E48F20AF3E5DB2038778E8@EXADV1.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2007-06-26 09:12:50 Re: Rule vs Trigger
Previous Message Richard Huxton 2007-06-26 08:54:00 Re: problem importing data with psql