libpq++ and arrays?
libpq++ and arrays?
От:
"Alf Lewerken" <lewerken@mail.bicos.de>
Дата:
Hi all
I have the following problem:
I'm using libpq++ to acces a Postgres-Database.
The table was created in psql using:
create table test values (nr int4, some_value float4[]);
in my C++-program a piece of code is:
main()
{
char *nr_string, *some_other_string;
PgDatabase test(pgenv, "test");
test.Exec("begin");
test.Exec("declare c cursor for select * from test");
for(int i=0; i<test.Tuples();i++)
{
nr_string = test.GetValue(i, "nr"); // obtaining the value in 'nr' is easy
some_other_string = test.GetValue(i, "some_value[1]"); // this gives an error
// PQgetvalue: ERROR! field number -1 is out of range
// so how do I obtain values in some_value[1], some_value[2] .... ?
}
}
any help would be appreciated.
bye
Alf Lewerken
Re: [INTERFACES] libpq++ and arrays?
От:
"Patrick Welche" <prlw1@newn.cam.ac.uk>
Дата:
Alf Lewerken wrote:
>
> I have the following problem:
> I'm using libpq++ to acces a Postgres-Database.
>
> The table was created in psql using:
> create table test values (nr int4, some_value float4[]);
...
> // so how do I obtain values in some_value[1], some_value[2] .... ?
How about
create table test (nr int4, some_value float4[]);
insert into test values (1,'{1,2,3}');
insert into test values (2,'{2,4,6}');
insert into test values (3,'{3,6,9}');
#include
#include
int main()
{ const char *nr_string, *val1, *val2;
PgDatabase test("test"); test.Exec("select nr,test.some_value[1] as val1, test.some_value[2] as val2 " "from test"); for(int i=0; ijava and postgresql 6.5
От:
<yves@vlaanderen.net>
Дата:
I've been upgrading postgresql 6.4.2 to 6.5. It seems like the jdbc driver
included with postgres 65 doesn't work correctly:
java.lang.IllegalArgumentException: Argument # > Arg length
or am i doing something wrong ?
-Yves
On Fri, 14 May 1999, Alf Lewerken wrote:
> Hi all
>
> I have the following problem:
> I'm using libpq++ to acces a Postgres-Database.
>
> The table was created in psql using:
> create table test values (nr int4, some_value float4[]);
>
> in my C++-program a piece of code is:
>
> main()
> {
> char *nr_string, *some_other_string;
>
> PgDatabase test(pgenv, "test");
> test.Exec("begin");
> test.Exec("declare c cursor for select * from test");
>
> for(int i=0; i {
> nr_string = test.GetValue(i, "nr"); // obtaining the value in 'nr' is easy
>
> some_other_string = test.GetValue(i, "some_value[1]"); // this gives an error
> // PQgetvalue: ERROR! field number -1 is out of range
>
> // so how do I obtain values in some_value[1], some_value[2] .... ?
> }
> }
>
> any help would be appreciated.
>
>
> bye
>
>
> Alf Lewerken
>
=================================================================
First, they ignore you.
Then they laugh at you.
Then they fight you.
Then you win. -- M. Ghandi