Using pgAdmin III, I want to create tables in my postgres DB using a PL/pgSQL function specifically. The following set of commands does the job fine for me.
Create or Replace Function mk_tbl()
Returns Integer As $$
Declare
Begin
Drop Table if exists sel_streets;
Create Table sel_streets
(
id Integer,
Geom geometry
);
Create Index sel_streets_indx
ON sel_streets Using
gist (geom);
Return (1);
End $$ Language plpgsql volatile;
I am calling the function by this command:
Select mk_tbl();
My problem is every time I call this function, it creates tables in postgres DB as well as it returns '1' (in SQL editor output panel) which is not desired. I am aware that ultimately a function should return something and I can also use void construct like this:
Create or Replace Function mk_tbl()
Returns Void As $$
...
However, what I want is to call this function which should only create tables in my potgres DB and should return nothing. Is it possible to do this using PL/pgSQL specifically?
returns void(Unrelated: the language name is an identifier, don't put it in single quotes:language plpgsqlshould be used).do $$ begin perform mk_tbl(); end;$$;