X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C69E73A457F for ; Thu, 18 Nov 2004 19:28:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09342-03 for ; Thu, 18 Nov 2004 19:28:11 +0000 (GMT) Received: from ns2.cfdsbank.com (ns2.cfdsbank.com [208.23.76.252]) by svr1.postgresql.org (Postfix) with ESMTP id C172D3A4752 for ; Thu, 18 Nov 2004 19:28:10 +0000 (GMT) Received: from srvexchcheyenne.c1data.com (SrvExchCheyenne [10.100.1.242]) by ns2.cfdsbank.com (Postfix) with ESMTP id 1F3B6272C68 for ; Thu, 18 Nov 2004 12:28:09 -0700 (MST) Received: by srvexchcheyenne.c1data.com with Internet Mail Service (5.5.2653.19) id <4BYPM282>; Thu, 18 Nov 2004 12:28:09 -0700 Message-ID: <07CF70EF155E0F46B8C658298805581DD2E264@srvexchcheyenne.c1data.com> From: Justine.Cleary@c1data.com To: pgsql-sql@postgresql.org Subject: missing... at end of sql expression Date: Thu, 18 Nov 2004 12:28:03 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C4CDA4.B92683FA" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.4 tagged_above=0.0 required=5.0 tests=HTML_70_80, HTML_MESSAGE, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200411/218 X-Sequence-Number: 19537 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C4CDA4.B92683FA Content-Type: text/plain 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'; ------_=_NextPart_001_01C4CDA4.B92683FA Content-Type: text/html Content-Transfer-Encoding: quoted-printable

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 :=3D''\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<= font size=3D2 face=3DArial> enrollment.stdid =3D 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<= font size=3D2 face=3DArial> enrollment.stdid =3D cast(student.stdid as char(4)) and student.advid = =3D advisor.advid and enrollment.crs =3D 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 :=3D text_output || row_data.crs ||''\n''; =

 

 

    = END LOOP;<= /p>

end = loop;

 

      -- = Return the list of books.

    = RETURN text_output;

  = END;

' = LANGUAGE = 'plpgsql';

 

------_=_NextPart_001_01C4CDA4.B92683FA--