How to execute pgsql script in pgAdmin?

I want to execute several pgScript directly from the pgAdmin editor interface.

FOR i IN 1..10 LOOP PRINT i; -- i will take on the values 1,2,3,4,5,6,7,8,9,10 within the loop END LOOP; 

But I always got

 [ERROR ] 1.0: syntax error, unexpected character 

I also tried to wrap the code with do $$ ... $$ , but does not solve the problem.

+7
plpgsql postgresql pgadmin
source share
2 answers

other than the posted response by Clodoaldo Neto . You can try it and

 DO $$ BEGIN FOR i IN 1..10 LOOP RAISE NOTICE '%', i; -- i will take on the values 1,2,3,4,5,6,7,8,9,10 within the loop END LOOP; END $$ 
+13
source share

No PRINT command. Use raise notice instead.

 create function f() returns void as $$ begin FOR i IN 1..10 LOOP raise notice '%', i; -- i will take on the values 1,2,3,4,5,6,7,8,9,10 within the loop END LOOP; end; $$ language plpgsql; 

http://www.postgresql.org/docs/current/static/plpgsql.html

+1
source share

All Articles