postgresql - How invoke PL/pgSQL from command line instead of SQL -
i write pl/sql scripts using oracle , i'm trying first pl/pgsql script postgresql. example, created test.sql file.
declare v_loc_nbr integer; begin v_loc_nbr := 0; end;
which try execute using command line:
\postgresql\9.3\bin\psql.exe -d postgres -f test.sql
but syntax errors like:
psql:test.sql:4: error: syntax error @ or near "v_loc_nbr"
i think problem trying execute sql when want run pl/pgsql. should command be?
i don't want explain more because erwin explained well.you need wrap sql inside do, test.sql
should write this
do $$ declare v_loc_nbr integer; begin v_loc_nbr := 0; end; $$
and try execute \postgresql\9.3\bin\psql.exe -d postgres -f test.sql
Comments
Post a Comment