functions

From: Kent Scott <kscott(at)logicalsi(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: functions
Date: 2010-03-27 21:34:53
Message-ID: 4BAE79FD.6040000@logicalsi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I am having a hard time coming from MS SQL in terms of creating
functions. Minor things keep you from being able to create functions
that are not an issue in MS SQL so I need help in understanding why they
are an issue so that I can ultimately create the functions that I need
to. I can create and run the following function fine :

CREATE FUNCTION listSales(dt date,movie text) RETURNS SETOF ticket AS
$$
BEGIN
select * from ticket where date = $1 and mov_num = $2;
END;
$$
LANGUAGE SQL;

however, the following will not create :
CREATE FUNCTION listSales(dt date,movie text) RETURNS SETOF ticket AS
$$
declare
r1 int;
BEGIN
select * from ticket where date = $1 and mov_num = $2;
END;
$$
LANGUAGE SQL;

I get a syntax error on r1 int and I have no idea why. Am I not allowed
to declare variables if they are not used?

Thanks,

Kent

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jasen Betts 2010-03-28 02:44:14 Re: functions
Previous Message dipti shah 2010-03-27 10:03:47 Re: Get the list of permissions/privileges on schema