Accessing geometric values from embedded SQL

From: Tony Griffiths <tony(dot)griffiths(at)cs(dot)man(dot)ac(dot)uk>
To: pgsql-nov <pgsql-novice(at)postgresql(dot)org>
Subject: Accessing geometric values from embedded SQL
Date: 2002-06-27 16:26:00
Message-ID: 3D1B3C98.8E59BF04@cs.man.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,
I'm really stuck with this one, so any help greatly appreciated....

If I create a table BBoxes with the definition:

create table BBoxes(
bbox box
);

that is suitably initialised with boxes, then issue the following sql
embedded in C:

EXEC SQL BEGIN DECLARE SECTION;
char ret_bbox[500];
EXEC SQL END DECLARE SECTION;

strcpy(query_string, "(1,1),(5,5)");

EXEC SQL DECLARE bbox_curs CURSOR FOR SELECT bbox FROM BBoxes;
exec sql whenever not found do break;
EXEC SQL OPEN bbox_overlaps_curs;

for(;;) {
EXEC SQL FETCH bbox_overlaps_curs into :ret_bbox;
}

I get the following problems:

1) ret_bbox always contains an empty string
2) the fetch operation's sqlca.sqlcode always is -211 (DATA_NOT_ARRAY)

I've also tried (in desperation) declaring the cursor as:

EXEC SQL DECLARE bbox_curs CURSOR FOR SELECT box(bbox) FROM BBoxes;

I've also (again in desperation) tried the following:

exec sql type POINT is struct { double x; double y; };
exec sql type BOX is struct { POINT high; POINT low; };
EXEC SQL BEGIN DECLARE SECTION;
BOX ret_bbox;
EXEC SQL END DECLARE SECTION;

with the same code, and still get the -211 error, and the fields of
ret_bbox, containing gibberish.

Any ideas about how to do this, or how to do this with ADTs in general
would be appreciated.

Many thanks,

--
Tony

---------------------------------
Dr. Tony Griffiths
Research Fellow
Information Management Group,
Department of Computer Science,
The University of Manchester,
Oxford Road,
Manchester M13 9PL,
United Kingdom

Tel. +44 (0) 161 275 6139
Fax +44 (0) 161 275 6236
email tony(dot)griffiths(at)cs(dot)man(dot)ac(dot)uk
---------------------------------

Browse pgsql-novice by date

  From Date Subject
Next Message James Kelty 2002-06-27 18:45:30 NFS/NAS
Previous Message Ewald Geschwinde 2002-06-27 16:07:17 Re: running from a script