Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

my first function

$
0
0
Hello all. I am new to PostgreSQL and trying to write my first function. I followed the samples in documentation and I wrote the function below:

Code:

CREATE OR REPLACE FUNCTION TEST() RETURNS TABLE (today DATE) AS'
 DECLARE today DATE;
 BEGIN
    today = current_date;
 END;'
LANGUAGE plpgsql;

select * from TEST();

Instead of "today=current_date" I also tried "select current_date into today", and several other things. Here, I expect to see a table with a column containing today's date. But I see an empty table. Could you please tell me what I am doing wrong? Thanks.

Viewing all articles
Browse latest Browse all 13329

Trending Articles