Trying to avoid a simple temporary variable declaration in a pl/pgsql function

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Trying to avoid a simple temporary variable declaration in a pl/pgsql function
Date: 2015-06-20 14:23:41
Message-ID: CAKFQuwaeOM0RTeYjCSozYTc83MEN==kJ2OKhtWk+LZtNoPSo-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I know this could be written quite easily in sql but was wondering if it is
possible in pl/pgsql.

CREATE FUNCTION test_func()
RETURNS text
LANGUAGE 'plpgsql'
AS $$
BEGIN
SELECT 'text_to_return' INTO <what_goes_here?>; --with or without a cast
RETURN <what_goes_here?>;
END;
$$;

The goal is to return the value of text_to_return without declaring an
explicit variable to name in the INTO clause.

I thought there was an implicit variable available to me but cannot figure
out what it is nor find it in the documentation.

Using 9.3 but figuring if it is possible its likely the same in all
supported releases...

Thanks!

David J.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2015-06-20 14:56:44 Re: Trying to avoid a simple temporary variable declaration in a pl/pgsql function
Previous Message Sameer Kumar 2015-06-20 12:14:41 Re: WAL log archival on standby