Column names as variables in plpgsql - Mailing list pgsql-novice

From Derrick Betts
Subject Column names as variables in plpgsql
Date
Msg-id 0eb901c69c95$17ccdd80$0202a8c0@main
Whole thread Raw
In response to Re: insert more than one rows  ("Andrej Ricnik-Bay" <andrej.groups@gmail.com>)
Responses Re: Column names as variables in plpgsql
List pgsql-novice
Is it possible to assign a column name to a variable and then use that
variable in a SELECT statement inside a function using plpgsql?

For example:

CREATE OR REPLACE FUNCTION function_name("varchar")
  RETURNS varchar AS
$BODY$
DECLARE
column_name alias for $1;
status varchar;
BEGIN
  SELECT column_name INTO status FROM contact_table WHERE id = 1;
RETURN status;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

Thanks,
Derrick



pgsql-novice by date:

Previous
From: Christopher Browne
Date:
Subject: Re: postgres in realtime mode
Next
From: "Tomer Levinboim"
Date:
Subject: postgres transaction isolation when rollback