Re: How return a row from a function so it is recognized as such by caller?

From: Kenneth Tilton <ktilton(at)mcna(dot)net>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How return a row from a function so it is recognized as such by caller?
Date: 2012-03-28 19:49:46
Message-ID: CAECCA8a36c0Q_jqj082sj8_+PKLK=5h1ysp-XKX08__KKCYQBQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
>
>
On Wed, Mar 28, 2012 at 3:40 PM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:

> On Wed, Mar 28, 2012 at 2:08 PM, Kenneth Tilton <ktilton(at)mcna(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2012-03-28 20:02:16 Re: How return a row from a function so it is recognized as such by caller?
Previous Message Merlin Moncure 2012-03-28 19:40:20 Re: How return a row from a function so it is recognized as such by caller?