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

Re: How to use embedded sql to define an array

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: How to use embedded sql to define an array
Date: 2002-06-12 12:34:07
Message-ID: 20020612123407.GE30292@feivel.credativ.de (view raw or flat)
Thread:
Lists: pgsql-interfaces
On Mon, Jun 10, 2002 at 11:07:52AM -0500, Jeffrey Graham wrote:
> Can someone please tell me how to declare an array of double (float8) 
> using esql  when you
> don't know how long the array is until runtime?

How do you define the attribute in pgsql? I take it you cannot enter a
dimension here either.

>...
>        for ( unsigned int i=0; i < myVector.length(); i++ )
>                m_data[i] = myVector[i];
> 
>        EXEC SQL
>                insert into eraDATA
>                      ( data )
>                VALUES(  :m_data );
>        return sqlOK();

If you just need a way to insert the data you could write your data to a
string together with the insert command so that you end up with a
string:

insert into eraDATA ( data ) VALUES('{1,2,3,....}')

This string can be executed using EXECUTE IMMEDIATE.

Or did you mean something else?

Hope this helps.

Michael
	 
-- 
Michael Meskes
Michael(at)Fam-Meskes(dot)De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!

In response to

pgsql-interfaces by date

Next:From: Nookala Satish KumarDate: 2002-06-12 12:52:52
Subject: Re: unable to create postgresql.jar
Previous:From: Bruce MomjianDate: 2002-06-12 03:44:43
Subject: Re: Schemas and template1

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