PL/pgSQL function syntax question? - Mailing list pgsql-sql

From Ruben Gouveia
Subject PL/pgSQL function syntax question?
Date
Msg-id 51e507b0809081440h2bd96f56md842410e80103965@mail.gmail.com
Whole thread Raw
Responses Re: PL/pgSQL function syntax question?  (Lennin Caro <lennin.caro@yahoo.com>)
List pgsql-sql
<div dir="ltr">i get the following error when i try and create the following function:<br /><br />Basically, i am
tryingto have two different dates compared and only the most recent returned to me.  This seems pretty straight
forward,what I am doing wrong here?<br /><br /><span style="color: rgb(51, 51, 255);">create or replace function
fcn_pick_date(v_dtdate) <br />returns date as $$  <br />  DECLARE<br />      v_dt date; <br />  BEGIN<br />    for
v_recordin select last_periodic, last_boot<br />         from mediaportal<br />    loop<br />    if v_dt >=
v_record.last_bootthen<br />       v_dt := v_record.last_periodic;<br />    else<br />        v_dt :=
v_record.last_boot;<br/>    end if;<br />    end loop;<br />    return (v_dt);<br /> END;<br />$$ LANGUAGE
'plpgsql';</span><br/><br /><br /><span style="color: rgb(204, 0, 0);">ERROR:  loop variable of loop over rows must be
recordor row variable at or near "loop" at character 195<br /><br />********** Error **********<br /><br />ERROR: loop
variableof loop over rows must be record or row variable at or near "loop"<br />SQL state: 42601<br />Character: 195<br
/></span><br/><br /></div> 

pgsql-sql by date:

Previous
From: Devrim GÜNDÜZ
Date:
Subject: Re: psql: FATAL: Ident authentication failed for user "postgres"
Next
From: aklaver@comcast.net (Adrian Klaver)
Date:
Subject: Re: PL/pgSQL function syntax question?