Search Postgresql Archives

Datum problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx - Skype:sscotty71
http://www.linuxtime.it/enricopirozzi


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux