Inserting arrays from C program - Mailing list pgsql-novice

From Yadnyesh Joshi
Subject Inserting arrays from C program
Date
Msg-id 20061017034829.17323.qmail@web53210.mail.yahoo.com
Whole thread Raw
List pgsql-novice
Hi,
Let's say we have a table arrin with only coloumn being pos int[]
To insert values into this table, a normal query would be
insert into arrin values ('{5,5,5,5}');
Bow, I have a C program which has an integer array say arr.
Now, I want to insert values from this arr array into the 'arrin' table.
One way to do that is create a string, say s, which will have '{<comma separated elements of arr>}'
and then use EXEC SQL INSERT INTO arrin VALUES (:s);
But, is there a better/direct way to insert array? I mean can I use integer array 'arr' as host variable?
something like EXEC SQL INSERT INTO arrin VALUES (:arr) ; ?
Thank you,
Yadnyesh.


Find out what India is talking about on - Yahoo! Answers India
Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW

pgsql-novice by date:

Previous
From:
Date:
Subject: Re: pg_dump, pg_restore and UTF8: invalid byte sequence
Next
From: Michael Fuhr
Date:
Subject: Re: Using host variables -- segmentation fault