Re: How return a row from a function so it is recognized as such by caller? - Mailing list pgsql-general

From Kenneth Tilton
Subject Re: How return a row from a function so it is recognized as such by caller?
Date
Msg-id CAECCA8a36c0Q_jqj082sj8_+PKLK=5h1ysp-XKX08__KKCYQBQ@mail.gmail.com
Whole thread Raw
In response to Re: How return a row from a function so it is recognized as such by caller?  (Merlin Moncure <mmoncure@gmail.com>)
Responses Re: How return a row from a function so it is recognized as such by caller?
List pgsql-general


On Wed, Mar 28, 2012 at 3:40 PM, Merlin Moncure <mmoncure@gmail.com> wrote:
On Wed, Mar 28, 2012 at 2:08 PM, Kenneth Tilton <ktilton@mcna.net> wrote:
> Thanks, Merlin. Maybe I have some subtle detail wrong. When
> NEW.warn_time_init is 'now_plus_30' and I have this as my execute statement:
>
>         execute NEW.warn_time_init || '($1)' into bpa using NEW;
>
> ...I get:
>

your'e missing a 'select' in there.  functions must be called through
select (just like you can't call a function by name in psql without
it).


Well then I have the other error. With this code:

   execute 'select ' || NEW.warn_time_init || '($1)' into bpa using NEW;

I get:

NOTICE:  bpa inbound (,now_plus_30)
CONTEXT:  SQL statement "select now_plus_30($1)"
PL/pgSQL function "bp_alert_init" line 6 at EXECUTE statement
NOTICE:  warn time in input row = ("2012-04-27 19:04:37.793835+00",now_plus_30)
CONTEXT:  SQL statement "select now_plus_30($1)"
PL/pgSQL function "bp_alert_init" line 6 at EXECUTE statement


ERROR:  invalid input syntax for type timestamp with time zone: "("2012-04-27 19:04:37.793835+00",now_plus_30)"
CONTEXT:  PL/pgSQL function "bp_alert_init" line 6 at EXECUTE statement

********** Error **********

ERROR: invalid input syntax for type timestamp with time zone: "("2012-04-27 19:04:37.793835+00",now_plus_30)"
SQL state: 22007
Context: PL/pgSQL function "bp_alert_init" line 6 at EXECUTE statement


I guess you are right, though. This is the error I have to resolve.

Thx,
-kt

pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: How return a row from a function so it is recognized as such by caller?
Next
From: Merlin Moncure
Date:
Subject: Re: How return a row from a function so it is recognized as such by caller?