How to print values inside a loop in postgresql?

6.4k views Asked by At

This question might seem to be a possible duplicate of How to print values in the loop. Even though the particular link contains a good solution it, doesn't seems to work for me. This is the core part of the stored procedure that I've written.

BEGIN 
FOR i IN 1..10 LOOP
    RAISE NOTICE 'i is %',i;
END LOOP;
RETURN; 
END; 

While executing the procedure I'm always getting the result as

No rows found.

Total runtime: 1.787 ms

SQL executed.

Can someone tell me how to print the value of i? The postgresql version that I'm using is 8.4. Any help is greatly appreciated.

1

There are 1 answers

1
Pavel Stehule On BEST ANSWER

The code looks well. There are few possibilities:

  • your client doesn't show asynchronous messages correctly
  • you have higher client_min_messages than notice- can be changed by command:

    SET client_min_messages TO notice;
    

  • you are looking to wrong window - Server messages are shown in other window than result usually. In pgAdmin, you have to choose a tab Messages