Noobie
Noobie

Reputation: 581

Unable to get the SQL function to run

I'm unable to get a simple SQL function that run over rows of a tables and display it column info Here how the SQL function looks like.

CREATE OR REPLACE FUNCTION iterators() RETURNS Void AS $$
 DECLARE
    t2_row call_records%ROWTYPE;
 BEGIN
    FOR t2_row IN (SELECT timestamp,plain_crn INTO call_records limit 2)
    LOOP
   RAISE NOTICE t2_row.timestamp;
   END LOOP
 END
$$ LANGUAGE plpgsql;

But I keep getting following error

ERROR:  syntax error at or near "t2_row"
LINE 7:     RAISE NOTICE t2_row.timestamp;

I'm not sure what possible syntax error the code has? Is it possible to get a bit more verbose error log or know as to what is the syntax error in code that I have to fix.

Upvotes: 0

Views: 31

Answers (1)

Pavel Stehule
Pavel Stehule

Reputation: 45825

Statement RAISE requires format string. It should be trivial, but should be there.

RAISE NOTICE '%', t2_row.timestamp;

Upvotes: 2

Related Questions