From: | Thomas Lockhart <thomas(at)fourpalms(dot)org> |
---|---|
To: | Michael Meskes <meskes(at)postgresql(dot)org> |
Cc: | Nicolas Bazin <nbazin(at)ingenico(dot)com(dot)au>, pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: ecpg weird behavior |
Date: | 2002-03-20 03:46:04 |
Message-ID: | 3C9805FC.1F69702D@fourpalms.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
> > ... have an Oracle extension to use a cursor to select multiple
> > rows into variables declared as arrays. Have you run into this syntax or
> > thought about what it would take to implement it?
> Do you mean like this:
> exec sql begin declare section;
> int amount[6];
> char name[6][8];
> exec sql end declare section;
> ...
> exec sql select * into :name, :amount from "Test";
No (although I was not aware that the above would work). The example
looks like
exec sql begin declare section;
char *name_arr[10];
exec sql end declare section;
exec sql declare names cursor for
select name from horses;
strcpy(msg, "open");
exec sql open names;
exec sql fetch names into :name_arr;
exec sql close names;
So the syntax uses a cursor fetching into an array, rather than a
"select into". A couple of details on behavior from the Oracle docs:
Each FETCH returns, at most, the number of rows in the array
dimension.
Fewer rows are returned in the following cases: <snip cases>
The cumulative number of rows returned can be found in the third
element
of sqlerrd in the SQLCA, called sqlerrd[2] in this guide.
The Oracle docs at the following URL are consistant with the examples I
was seeing:
http://www-rohan.sdsu.edu/doc/oracle/server803/A54661_01/arr.htm#512
I'm guessing that this is a relatively short hop from your existing
array capabilities, but don't how close. What do you think?
- Thomas
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Kretzer | 2002-03-20 16:31:54 | Re: Problem with pgaccess |
Previous Message | Nicolas Bazin | 2002-03-20 03:15:06 | Re: ecpg weird behavior |