Search Postgresql Archives

Re: Datum problem

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

 



On Thu, Nov 09, 2006 at 06:12:08PM +0100, Enrico wrote:
> 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:

Well, you didn't actually call any function, so it just returned the
two parameters as you asked... You have other problems though.

> visualizza_esistenza(PG_FUNCTION_ARGS)
> {
>     HeapTupleHeader  t = PG_GETARG_HEAPTUPLEHEADER(0);
>     int16            limit = PG_GETARG_INT16(1);

An "integer" is not an "int16", so this is wrong, you want INT32

>     bool isnull;
>     Datum esistenza;
>     int16 es;
> 
>     esistenza = GetAttributeByName(t, "esistenza", &isnull);
>     es = DatumGetInt16(esistenza);

Possibly same problem here.

>     if (esistenza > limit)
>       PG_RETURN_INT16(es);

You declared you were going to return an int4, yet you're returing
something else.

> }

What are you returning if the if statement doesn't get run?

Hope this helps,
-- 
Martijn van Oosterhout   <kleptog@xxxxxxxxx>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment: signature.asc
Description: Digital signature


[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