X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 84602476340 for ; Wed, 26 Mar 2003 13:47:40 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id E2DC6476341 for ; Wed, 26 Mar 2003 13:47:39 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id C001F43A611; Wed, 26 Mar 2003 13:47:39 -0500 (EST) From: gar8@pitt.edu (Tony Reina) X-Newsgroups: comp.databases.postgresql.sql Subject: How can I pass an array from PostgreSQL to C (libpq)? Date: 26 Mar 2003 10:24:46 -0800 Organization: http://groups.google.com/ Lines: 16 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-6.6 required=5.0 tests=BAYES_01 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/588 X-Sequence-Number: 12626 I'm using the C library (lipq) to grab data from a field that contains a float array (float4[]). I'd like to fill an array in my C program with these values. Unfortunately, Postgres returns the array as a large string instead of individual values. Now I could perform "select array_var[1], array_var[2], array_var[3], ..., array_var[4]" and have each array value come back as a different field, but this seems fairly messy. I suppose I could also go through and parse the characters in the string returned. Has anyone else used any other strategies to fill their C array with an array returned from the libpq? Perhaps there are some SQL functions for arrays that might exist? Thanks. -Tony