Re: [GENERAL] Trying to avoid a simple temporary variable declaration in a pl/pgsql function

2015-06-20 Thread Tom Lane
David G. Johnston david.g.johns...@gmail.com writes: 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

Re: [GENERAL] Trying to avoid a simple temporary variable declaration in a pl/pgsql function

2015-06-20 Thread David G. Johnston
On Sat, Jun 20, 2015 at 10:56 AM, Tom Lane t...@sss.pgh.pa.us wrote: David G. Johnston david.g.johns...@gmail.com writes: 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

Re: [GENERAL] Trying to avoid a simple temporary variable declaration in a pl/pgsql function

2015-06-20 Thread Jerry Sievers
David G. Johnston david.g.johns...@gmail.com writes: On Sat, Jun 20, 2015 at 10:56 AM, Tom Lane t...@sss.pgh.pa.us wrote: David G. Johnston david.g.johns...@gmail.com writes: I know this could be written quite easily in sql but was wondering if it is possible in pl/pgsql.

Re: [GENERAL] Trying to avoid a simple temporary variable declaration in a pl/pgsql function

2015-06-20 Thread Charles Clavadetscher
Hello The solution proposed by Tom works as long as you can make sure that your SELECT statement in the function will return a single row with a single column of type TEXT: CREATE TABLE test (id INTEGER, what_goes_here TEXT); INSERT INTO test values (1,'Text 1'); INSERT INTO test values