Datum problem

From: Enrico <scotty(at)linuxtime(dot)it>
To: Pg general <pgsql-general(at)postgresql(dot)org>
Subject: Datum problem
Date: 2006-11-09 17:12:08
Message-ID: 20061109181208.15722467@mypc.ricordatasystem.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
I'm newbie of programming postgresql sever side,
I write the function below and when I execute

SELECT (anag_art, 150) AS esistenza from anag_art order by 1;

result is something about this:

| esistenza |

("(""0000002 "",""ARTICOLO PREZ. VEND. "",,PZ,32,1,20,""1 "","" "","""",N,,0,-67.00000,-23.00000,,N,N)",150)

So postgresql outputs with a tuple, instead of an integer value as I wish.
Can anyone helps me?

Thanks in advantage.
Enrico

------------------- Start C code ---------------

#include "postgres.h"
#include "executor/executor.h"

PG_FUNCTION_INFO_V1(visualizza_esistenza);

Datum
visualizza_esistenza(PG_FUNCTION_ARGS)
{
HeapTupleHeader t = PG_GETARG_HEAPTUPLEHEADER(0);
int16 limit = PG_GETARG_INT16(1);
bool isnull;
Datum esistenza;
int16 es;

esistenza = GetAttributeByName(t, "esistenza", &isnull);
es = DatumGetInt16(esistenza);
if (esistenza > limit)
PG_RETURN_INT16(es);

}

------------------- End C code ---------------

CREATE OR REPLACE FUNCTION visualizza_esistenza(anag_art, integer) RETURNS int4
as '/home/scotty/enrico/postgresql_c/prova.so', 'visualizza_esistenza'
LANGUAGE C;

--
If Bill Gates had a penny for everytime Windows crashed,he'd be a multi-billionaire by now .......oh look, he already is !!!!
scotty(at)linuxtime(dot)it - Skype:sscotty71
http://www.linuxtime.it/enricopirozzi

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jorge Godoy 2006-11-09 17:14:13 Re: Why overlaps is not working
Previous Message Nathan Leon Pace, MD, MStat 2006-11-09 17:10:08 Mac OS X