Re: [GENERAL] helo

2010-02-25 Thread Wappler, Robert
On 2010-02-22, beulah prasanthi wrote:
 
 Helo
  I am working on spring project with postgres 8.4
 i wrote a function in postgrees which i am passing the
 argument email email[] array
 From front end we need to insesrt data into that emailarray
 .so i used java.arraylist.util
 while i am running i got the following error Please help me
 
 error:
 org.postgresql.util.PSQLException: Cannot cast an instance of
 java.util.ArrayList to type Types.ARRAY


The array support in JDBC is imo nothing better than horrible. However,
the way to go is:
Connection c = getConnection();
Array arr = c.createArrayOf(text, email);

PreparedStatement p = c.prepareStatement(...);
p.setArray(index, arr);

Also notice, that there is no nice way to test array data in frameworks
like DBUnit and others.


-- 
Robert...
 


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] helo

2010-02-22 Thread beulah prasanthi
Helo
 I am working on spring project with postgres 8.4
i wrote a function in postgrees which i am passing the argument email
email[] array
From front end we need to insesrt data into that emailarray .so i used
java.arraylist.util
while i am running i got the following error Please help me

error:
org.postgresql.util.PSQLException: Cannot cast an instance of
java.util.ArrayList to type Types.ARRAY


Re: [GENERAL] helo

2010-02-22 Thread Allan Kamau
On Mon, Feb 22, 2010 at 2:10 PM, beulah prasanthi itsbeu...@gmail.com wrote:
 Helo
  I am working on spring project with postgres 8.4
 i wrote a function in postgrees which i am passing the argument email
 email[] array
 From front end we need to insesrt data into that emailarray .so i used
 java.arraylist.util
 while i am running i got the following error Please help me

 error:
 org.postgresql.util.PSQLException: Cannot cast an instance of
 java.util.ArrayList to type Types.ARRAY


You have cross-posted.

You may want to compose a comma separated values string out of the
values you'd like to send as an array, Then send this string instead
of the array (ofcourse for your postgreSQL function, you will need to
change the datatype of your input variable to TEXT). Then inside your
postgres function unpack the CSV text into an array using some regular
expression(s).

maybe something like this.

Assuming _my_CSV_string is your text variable that contains the CSV data.

SELECT * FROM 
regexp_split_to_array(_my_CSV_string,E',(?=(?:[^\]*\[^\]*\)*(?![^\]*\))'))AS
my_array;



Allan.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] helo

2010-01-20 Thread beulah prasanthi
I am using postgres 8.4
using views i retrived some details from multiple tables
can i insert the data into multiple tables using views.if not
how can i insert the data into multiple tables in a single trip
is there any option .Please help me


Re: [GENERAL] helo

2010-01-20 Thread John R Pierce

beulah prasanthi wrote:

I am using postgres 8.4
using views i retrived some details from multiple tables
can i insert the data into multiple tables using views.if not
how can i insert the data into multiple tables in a single trip
is there any option .Please help me


use a transaction bracketed by BEGIN; and COMMIT;  to execute a series 
of inserts or updates as a single atomic operation.




--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] helo

2010-01-20 Thread A. Kretschmer
In response to beulah prasanthi :
 I am using postgres 8.4
 using views i retrived some details from multiple tables
 can i insert the data into multiple tables using views.if not
 how can i insert the data into multiple tables in a single trip
 is there any option .Please help me
 

You can use a RULE, simple example:

test=# create table a (a int);
CREATE TABLE
test=*# create table b (b int);
CREATE TABLE
test=*# commit;
COMMIT
test=# create view view_ab as select a.a, b.b from a left join b on a.a=b.b;
CREATE VIEW
test=*# commit;
COMMIT
test=# create rule rule_ab as on insert to view_ab do instead (insert into a 
values (new.a); insert into b values(new.b););
CREATE RULE
test=*# insert into view_ab values (1,1);
INSERT 0 1
test=*# select * from a;
 a
---
 1
(1 row)

test=*# select * from b;
 b
---
 1
(1 row)

test=*# select * from view_ab;
 a | b
---+---
 1 | 1
(1 row)

test=*#

Bernd Helme is working on 'updateable VIEWS', but i don't know the
actual status of this patch.

Upcoming new release (8.4+1) maybe contains writeable CTE, another way
to do this. (insert into multiple tables)

And yes, as said, you can use a transaction (begin; insert ...; insert
...; commit;)



Regards, Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: - Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general