missing... at end of sql expression

From: Justine(dot)Cleary(at)c1data(dot)com
To: pgsql-sql(at)postgresql(dot)org
Subject: missing... at end of sql expression
Date: 2004-11-18 19:28:03
Message-ID: 07CF70EF155E0F46B8C658298805581DD2E264@srvexchcheyenne.c1data.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I am trying to learn pspgsql but I am not having a lot of luck.

I have written a function but I keep getting the error missing... at end of
sql expression. Can anyone help!


CREATE FUNCTION exp101 () RETURNS text AS '
DECLARE


-- Declare a variable to hold book titles and set its default
-- value to a new line.
text_output TEXT :=''\n'';

-- Declare a variable to hold rows from the
-- books table.
--row_data enrollment%ROWTYPE;
--row_dataa student%ROWTYPE;

BEGIN

-- Iterate through the results of a query.
FOR row_data IN select *
from enrollment, student
where enrollment.stdid = cast(student.stdid as char(4))
Loop



FOR row_dataa IN select student.stdid , student.lname , student.fname
,student.mi, student.phone , student.major, advisor.lname, advisor.fname,
advisor.mi
from student, enrollment, advisor
where enrollment.stdid = cast(student.stdid as char(4)) and student.advid =
advisor.advid and enrollment.crs = row_data.crs order by student.lname,
student.fname, student.mi


Loop



-- Insert the title of a matching book into the text_output variable.
text_output := text_output || row_data.crs ||''\n'';


END LOOP;
end loop;

-- Return the list of books.
RETURN text_output;
END;
' LANGUAGE 'plpgsql';

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Nick Peters 2004-11-18 21:01:58 Comparing Dates
Previous Message Riccardo G. Facchini 2004-11-18 12:38:31 Re: session_id