i have table like below with name student
S.No Name
1. Ramesh
2. Raju
3. SOmu
-------------
------------- etc
My requirement is when i am passing the S.no i will get the Name by using function
My function like below:
CREATE OR REPLACE FUNCTION fn_name(v_sno bigint)
RETURNS TEXT
AS
$BODY$
DECLARE RESULT VARCHAR(5000);
BEGIN
SELECT RESULT "Name" FROM "Student" WHERE "s.no" = v_sno;
RETURN RESULT;
END;
$BODY$
LANGUAGE plpgsql
COST 100;
ALTER FUNCTION fn_name(bigint)
OWNER TO postgresql
but i am getting the following error .
ERROR: query has no destination for result data
SQL state: 42601
Hint: If you want to discard the results of a SELECT, use PERFORM instead.
Context: PL/pgSQL function fn_name(bigint) line 6 at SQL statement
please help me how to resolve the above issue.