Maping Oracle nvarchar2(lenght) to PostgreSQL varchar(lenght)

From: Jean-Michel POURE <jm(at)poure(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Maping Oracle nvarchar2(lenght) to PostgreSQL varchar(lenght)
Date: 2003-10-16 11:53:14
Message-ID: 200310161353.14203.jm@poure.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear friends,

I studying the possibility to port Compiere CRM from Oracle to PostgreSQL. As
Compiere evolves nearly everyday in CVS, I would like to run the Oracle code
without (too much) modification.

Don't blame me, I know using search/replace works most of the times.

At first, I used CREATE TYPE syntax to map Oracle nvarchar2 to PostgreSQL
varchar type (see code #1). The code seems to be the equivalent of:
CREATE DOMAIN nvarchar2 as varchar;

Now I can create tables with nvarchar2 but not nvarchar2(lenght).

Is there a way to map Oracle nvarchar2(lenght) to PostgreSQL nvarchar or
nvarchar(lenght) in PostgreSQL 7.3?

Are there plans to allow such mapping in the future using the CREATE DOMAIN
syntax?

Best regards,
Jean-Michel Pouré

**********************************************************************
Code #1
--DROP TYPE nvarchar2 CASCADE;

CREATE OR REPLACE FUNCTION oracle_nvarchar2in(cstring, oid, int4)
RETURNS nvarchar2 AS
'varcharin'
LANGUAGE 'internal' IMMUTABLE STRICT;
COMMENT ON FUNCTION oracle_nvarchar2in(cstring, oid, int4) IS '(internal)';

CREATE OR REPLACE FUNCTION oracle_nvarchar2out(nvarchar2)
RETURNS cstring AS
'varcharout'
LANGUAGE 'internal' IMMUTABLE STRICT;

CREATE TYPE nvarchar2
(INPUT=oracle_nvarchar2in, OUTPUT=oracle_nvarchar2out, DEFAULT='',
INTERNALLENGTH=-1, ALIGNMENT=int4, STORAGE=EXTENDED);
COMMENT ON TYPE nvarchar2 IS 'Oracle type nvarchar2(length) mapped to
PostgreSQL type varchar(lenght)';

Browse pgsql-general by date

  From Date Subject
Next Message Sebastian Boeck 2003-10-16 11:53:27 Re: easy way to insert same value into 2 columns
Previous Message Csaba Nagy 2003-10-16 11:21:38 Re: easy way to insert same value into 2 columns