Hi,

I have the following program :

#include <stdio.h>

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. 

Reply via email to