What is the proper syntax for PostgreSQL stored procedures (functions)?

From the Official Documentation CREATE OR REPLACE FUNCTION name ( argmode argname argtype { DEFAULT | = } default_expr , ... ) RETURNS rettype | RETURNS TABLE ( column_name column_type , ... ) { LANGUAGE lang_name | WINDOW | IMMUTABLE | STABLE | VOLATILE | CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT | EXTERNAL SECURITY INVOKER | EXTERNAL SECURITY DEFINER | COST execution_cost | ROWS result_rows | SET configuration_parameter { TO value | = value | FROM CURRENT } | AS 'definition' | AS 'obj_file', 'link_symbol' } ... WITH ( attribute , ... ) You will find your answer there and, maybe, learn two or three useful things on the process You might be particularly interested in the RETURNS TABLE construct.

From the Official Documentation CREATE OR REPLACE FUNCTION name ( argmode argname argtype { DEFAULT | = } default_expr , ... ) RETURNS rettype | RETURNS TABLE ( column_name column_type , ... ) { LANGUAGE lang_name | WINDOW | IMMUTABLE | STABLE | VOLATILE | CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT | EXTERNAL SECURITY INVOKER | EXTERNAL SECURITY DEFINER | COST execution_cost | ROWS result_rows | SET configuration_parameter { TO value | = value | FROM CURRENT } | AS 'definition' | AS 'obj_file', 'link_symbol' } ... WITH ( attribute , ... ) You will find your answer there and, maybe, learn two or three useful things on the process. You might be particularly interested in the RETURNS TABLE construct.

Hmm I'm having difficulty understanding all of the commands. Taking a look at my first function, for 'argtype' should I put 'IN' since I want to input values entered by user into the database? CREATE OR REPLACE FUCTION addto_car(IN model Car.

Model%type, IN year Car. Year%type) RETURNS void AS $$ BEGIN INSERT INTO Car VALUES(model, year); END; $$ LANGUAGE plpgsql; – tvguide1234 Aug 10 at 16:35 I don't necessarily want it to return the table, I just want it to insert the new tuple so I'm not sure if I should use "RETURN TABLE" or "RETURN VOID" – tvguide1234 Aug 10 at 16:40 1 Don't even use RETURN then. If you have problem figuring out the doc (that's understandable), take a look at the examples.

Some of them don't even have the RETURN clause. – Adrian 4 Aug7 at 16:54 Ah I see. I'm going to make a new version so to show a 'work in progress' version of my code.

– tvguide1234 Aug 10 at 17:06 OK I understand how to do function 1. For function 2 can I use RETURNS record? – tvguide1234 Aug 10 at 23:07.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions