Skip site navigation (1) Skip section navigation (2)

Re: is there a mysql to postgresql sql converter?

From: Max Fonin <fonin(at)ziet(dot)zhitomir(dot)ua>
To: Clayton Cottingham <clayton(at)marketingchallenge(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: is there a mysql to postgresql sql converter?
Date: 2000-11-18 12:08:47
Message-ID: 20001118140847.45895a34.fonin@ziet.zhitomir.ua (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-sql
Hi.

> > Can give a link ?
> can do :
> http://freshmeat.net/projects/mysql2pgsql/?highlight=convert+sql
Thank you.

BTW, if you interested in this tool, I may send you fresh versions or place it on the web.

Maybe you will or somebody help me with one problem ? Do you know PL/pgSQL and how to create new type in Postgres ?
The problem is that I can't use new type constructed with CREATE TYPE if transform functions written on PL/pgSQL.
Because PL/pgSQL doesn't support type "opaque", or I do something wrong. The same function on PL/pgSQL with 
input argtype "text" or "int2" works fine, but when I simply change argtype to "opaque", I get "compilation error near line 0".
Source is below.

Thanks,
Max Rudensky.

BEGIN;

CREATE FUNCTION enum_access_Monday_in (opaque)
	RETURNS enum_access_Monday
	AS '
	DECLARE
	    invalue ALIAS for $1;
	BEGIN
		IF invalue='''' OR invalue=''0'' THEN RETURN 0; END IF;
		IF invalue=''Monday'' OR invalue=''1'' THEN RETURN 1; END IF;
		IF invalue=''Tuesday'' OR invalue=''2'' THEN RETURN 2; END IF;
		IF invalue=''Wednesday'' OR invalue=''3'' THEN RETURN 3; END IF;
		RAISE EXCEPTION ''incorrect input value: %'',invalue;
	END;'
	LANGUAGE 'plpgsql'
	WITH (ISCACHABLE);
CREATE FUNCTION enum_access_Monday_out (opaque)
	RETURNS opaque
	AS '
	DECLARE
	    outvalue ALIAS for $1;
	BEGIN
		IF outvalue=0 THEN RETURN ''''; END IF;
		IF outvalue=1 THEN RETURN ''Monday''; END IF;
		IF outvalue=2 THEN RETURN ''Tuesday''; END IF;
		IF outvalue=3 THEN RETURN ''Wednesday''; END IF;
		RAISE EXCEPTION ''incorrect output value: %'',outvalue;
	END;'
	LANGUAGE 'plpgsql'
	WITH (ISCACHABLE);

CREATE TYPE enum_access_Monday (
	internallength = 2,
	input = enum_access_Monday_in,
	output = enum_access_Monday_out,
	PASSEDBYVALUE
);

COMMIT;

In response to

pgsql-sql by date

Next:From: Johann SpiesDate: 2000-11-18 17:57:58
Subject: Re: how many rows? [was Re: fetching rows]
Previous:From: Jonathan EllisDate: 2000-11-18 00:39:29
Subject: Re: [SQL] Requests for Development

pgsql-general by date

Next:From: DJKADate: 2000-11-18 14:05:19
Subject: About PostgreSQL large objects
Previous:From: Ellen SpertusDate: 2000-11-18 03:20:55
Subject: Comparing dates in 7.x

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group