Open a new sql pane editor
Uisng this script
CREATE OR REPLACE FUNCTION totalRecords ()
RETURNS integer AS $total$
declare
total integer;
BEGIN
SELECT count(*) into total FROM emp1;
RETURN total;
END;
$total$ LANGUAGE plpgsql;

Query was successful:

The code generated
-- Function: totalrecords()
-- DROP FUNCTION totalrecords();
CREATE OR REPLACE FUNCTION totalrecords()
RETURNS integer AS
$BODY$
declare
total integer;
BEGIN
SELECT count(fname) into total FROM emp1;
RETURN total;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION totalrecords()
OWNER TO manas237;
One you run this query:

Now call the procedure
|