Re: Datum problem

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Enrico <scotty(at)linuxtime(dot)it>
Cc: Pg general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Datum problem
Date: 2006-11-09 17:43:14
Message-ID: 20061109174314.GB23352@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2006-11-09 17:46:55 Re: Datum problem
Previous Message Anton Melser 2006-11-09 17:16:59 Re: autovacuum blues