Received: from shiva.jussieu.fr ([134.157.0.129]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f1JENDx67751 for ; Mon, 19 Feb 2001 09:23:57 -0500 (EST) (envelope-from klimann@liafa.jussieu.fr) Received: from mail.liafa.jussieu.fr (liafa1.liafa.jussieu.fr [132.227.81.128]) by shiva.jussieu.fr (8.10.0/jtpda-5.3.3) with ESMTP id f1JEKDf98800 for ; Mon, 19 Feb 2001 15:20:13 +0100 (CET) Received: from liafa0.liafa.jussieu.fr (liafa0.liafa.jussieu.fr [132.227.81.1]) by mail.liafa.jussieu.fr (8.9.3/jtpda-5.3.2) with ESMTP id PAA23265 for ; Mon, 19 Feb 2001 15:20:37 +0100 (MET) From: Ines.Klimann@liafa.jussieu.fr Received: from (klimann@localhost) by liafa0.liafa.jussieu.fr (8.9.3/jtpda-5.3.2) id PAA13115 for pgsql-sql@postgresql.org; Mon, 19 Feb 2001 15:20:37 +0100 Date: Mon, 19 Feb 2001 15:20:37 +0100 To: pgsql-sql@postgresql.org Subject: How to insert values with a new type ? Message-ID: <20010219152037.A12963@liafa0.liafa.jussieu.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre3us X-Archive-Number: 200102/304 X-Sequence-Number: 1500 Hi, I have the following program : #include typedef struct complexe { float x; float y; } complexe; complexe * complex_in(float x, float y) { complexe *result; result = (complexe *)palloc(sizeof(complexe)); result->x = x; result->y = y; return (result); } char * complex_out(complexe *complex) { char *result; if (complex == NULL) return(NULL); result = (char *) palloc(60); sprintf(result, "(%f,%f)", complex->x, complex->y); return(result); } (I took this from someone else...) Now, I do these SQL commands : CREATE FUNCTION complex_in(opaque) RETURNS complex AS '/ens/klimann/PostgreSQL/complexe.o' LANGUAGE 'c'; CREATE FUNCTION complex_out(opaque) RETURNS opaque AS '/ens/klimann/PostgreSQL/complexe.o' LANGUAGE 'c'; CREATE TYPE complex ( internallength = 16, input = complex_in, output = complex_out ); CREATE TABLE nombres ( val COMPLEX ); And I want to insert values in the table nombres. I have tried this : INSERT INTO nombres VALUES (complex_in(1.0, 4.0)); and this : INSERT INTO nombres VALUES (1.0, 4.0); and also this : INSERT INTO nombres VALUES ('1.0, 4.0'); and several other possibilities, but none seems to be right. Has someone an idea ? Thanks, Ines.