How to create stored procedure in postgresql?
1) Create Procedure
CREATE OR REPLACE PROCEDURE pgProcedure ()
as $$
BEGIN
SELECT
LastName
from persons;
END;
$$ LANGUAGE plpgsql;
2) Create Procedure with paramenter
CREATE OR REPLACE PROCEDURE pgProcedure (PersonID int )
as $$
BEGIN
SELECT
LastName
from persons where PersonID!=10;
END;
$$ LANGUAGE plpgsql;
3) Raise Notice rather than DBMS_OUTPUT.PUT_LINE
CREATE OR REPLACE PROCEDURE pgProcedure (PersonID int )
as $$
BEGIN
RAISE NOTICE ‘Messaage%’,PersonID;
SELECT
LastName
from persons where PersonID!=10;
END;
$$ LANGUAGE plpgsql;