Thread: Porting embedded SQL from Oracle to Postgres

Porting embedded SQL from Oracle to Postgres

From
"Daniel Clayton"
Date:
I am getting an error when attempting to compile using ecpg.

ERROR: syntax error at or near "TYPE"

This code was originally written for Oracle using Pro*/C

from header:

#define RAW_BUFFER_SIZE 524287
typedef struct {   long len;   char buffer[RAW_BUFFER_SIZE];
} internalCompiledData_t;

from .pgc :

EXEC SQL TYPE internalCompiledData_t is LONG VARRAW(RAW_BUFFER_SIZE);

static internalCompiledData_t compiledData;



It appears that the syntax EXEC SQL TYPE .. is ... ; is Oracle specific, is 
there a matching syntax for ecpg?
Or possibly a different way to achieve this datatype equivalencing?

Thanks in advance.
Daniel.

_________________________________________________________________
Find the coolest online games @ http://xtramsn.co.nz/gaming



Re: Porting embedded SQL from Oracle to Postgres

From
Michael Fuhr
Date:
On Mon, Oct 10, 2005 at 10:57:37AM +1300, Daniel Clayton wrote:
> It appears that the syntax EXEC SQL TYPE .. is ... ; is Oracle specific, is 
> there a matching syntax for ecpg?

ECPG appears to have at least some support for EXEC SQL TYPE: I see
code to handle it in preproc/preproc.y and some of the test programs
use it.  I haven't used it myself; maybe the programs in the source
code under src/interfaces/ecpg/test will provide helpful examples.

-- 
Michael Fuhr


Re: Porting embedded SQL from Oracle to Postgres

From
Michael Meskes
Date:
On Mon, Oct 10, 2005 at 10:57:37AM +1300, Daniel Clayton wrote:
> I am getting an error when attempting to compile using ecpg.
> 
> ERROR: syntax error at or near "TYPE"
> ...
> EXEC SQL TYPE internalCompiledData_t is LONG VARRAW(RAW_BUFFER_SIZE);

Just trying precompiling this statement gives:

t.pgc:1: ERROR: syntax error at or near "VARRAW"

And this is the expected result as ECPG does not know the VARRAW
datatype. I would be interested to implement this however if I find the
time.

> It appears that the syntax EXEC SQL TYPE .. is ... ; is Oracle specific, is 
> there a matching syntax for ecpg?
> Or possibly a different way to achieve this datatype equivalencing?

Could you send me a file where ecpg does not accept the TYPE command? It
should be available as long as you use variable types ecpg recognizes.

Michael
-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!