pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
missing... at end of sql expression
3+ messages / 3 participants
[nested] [flat]

* missing... at end of sql expression
@ 2004-11-18 19:28 Justine.Cleary@c1data.com
  2004-11-22 01:03 ` Re: missing... at end of sql expression Tom Lane <tgl@sss.pgh.pa.us>
  2004-11-22 01:09 ` Re: missing... at end of sql expression Michael Fuhr <mike@fuhr.org>
  0 siblings, 2 replies; 3+ messages in thread

From: Justine.Cleary@c1data.com @ 2004-11-18 19:28 UTC (permalink / raw)
  To: 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';
 

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: missing... at end of sql expression
  2004-11-18 19:28 missing... at end of sql expression Justine.Cleary@c1data.com
@ 2004-11-22 01:03 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2004-11-22 01:03 UTC (permalink / raw)
  To: Justine.Cleary@c1data.com; +Cc: pgsql-sql

Justine.Cleary@c1data.com writes:
> 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!

What it's really unhappy about is that you failed to declare the FOR
variable; this is causing it to assume that the FOR is the integer
variant (FOR i IN low .. high).

The error message is pretty confusing, I agree.  I think 8.0 will
do better.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: missing... at end of sql expression
  2004-11-18 19:28 missing... at end of sql expression Justine.Cleary@c1data.com
@ 2004-11-22 01:09 ` Michael Fuhr <mike@fuhr.org>
  1 sibling, 0 replies; 3+ messages in thread

From: Michael Fuhr @ 2004-11-22 01:09 UTC (permalink / raw)
  To: Justine.Cleary@c1data.com; +Cc: pgsql-sql

On Thu, Nov 18, 2004 at 12:28:03PM -0700, Justine.Cleary@c1data.com wrote:

>     --row_data enrollment%ROWTYPE;
>     --row_dataa student%ROWTYPE;

Your loop variables are commented out.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-11-22 01:09 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-11-18 19:28 missing... at end of sql expression Justine.Cleary@c1data.com
2004-11-22 01:03 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-11-22 01:09 ` Michael Fuhr <mike@fuhr.org>

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