insert values

From: Ines(dot)Klimann(at)liafa(dot)jussieu(dot)fr
To: pgsql-sql(at)postgresql(dot)org
Subject: insert values
Date: 2001-02-22 12:52:22
Message-ID: 20010222135222.A14873@liafa0.liafa.jussieu.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I have the following type :
--------------------------------------------
CREATE FUNCTION entier_in(opaque)
RETURNS entier
AS '/ens/klimann/PostgreSQL/entier.o'
LANGUAGE 'c';

CREATE FUNCTION entier_out(opaque)
RETURNS opaque
AS '/ens/klimann/PostgreSQL/entier.o'
LANGUAGE 'c';

CREATE TYPE entier (
internallength = 8,
input = entier_in,
output = entier_out
);
--------------------------------------------

where entier.c is the following program :
--------------------------------------------
#include <stdio.h>

typedef struct entier {
long x;
} entier;

entier * entier_in(char *s)
{
entier *result;

result = (entier *)malloc(sizeof(entier));
result->x = atoi(s);

return (result);
}

char * entier_out(entier *n)
{
char *result;
if (n == NULL)
return(NULL);
result = (char *) malloc(60);
sprintf(result, "%d", n->x);

return(result);
}
----------------------------------------------

then I create the table entiers as follows :
----------------------------------------------
CREATE TABLE entiers (
val entier
);
----------------------------------------------

How can I insert a value in this table ?

I have tried several methods, but I can't find
a correct one.

Does someone have an idea ?

Thanks a lot,
Ines.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2001-02-22 14:29:35 Re: problem with dates
Previous Message postgresql 2001-02-22 12:26:17 problem with dates