Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print values inside a loop in postgresql?

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.

like image 606
harry Avatar asked Oct 15 '25 15:10

harry


1 Answers

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

like image 184
Pavel Stehule Avatar answered Oct 18 '25 05:10

Pavel Stehule



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!