pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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
Message-ID: <07CF70EF155E0F46B8C658298805581DD2E264@srvexchcheyenne.c1data.com> (raw)

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';
 

view thread (3+ messages)  latest in thread

Message-ID: <07CF70EF155E0F46B8C658298805581DD2E264@srvexchcheyenne.c1data.com>
Permalink:  ../07CF70EF155E0F46B8C658298805581DD2E264@srvexchcheyenne.c1data.com/
Also on:    postgresql.org/message-id/07CF70EF155E0F46B8C658298805581DD2E264@srvexchcheyenne.c1data.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Justine.Cleary@c1data.com
  Subject: Re: missing... at end of sql expression
  In-Reply-To: <07CF70EF155E0F46B8C658298805581DD2E264@srvexchcheyenne.c1data.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox