Skip site navigation (1) Skip section navigation (2)

Re: error : syntax error at or near $1 for over select rows

From: John DeSoi <desoi(at)pgedit(dot)com>
To: "vinita bansal" <sagivini(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: error : syntax error at or near $1 for over select rows
Date: 2004-12-27 18:51:25
Message-ID: 4F07B1D4-5838-11D9-B0A0-000A95B03262@pgedit.com (view raw or flat)
Thread:
Lists: pgsql-general
On Dec 27, 2004, at 11:36 AM, vinita bansal wrote:

>        FOR for1 in select qi.tril_gid as 
> vQuotaInstanceGID,qi.startdate as vQIStartDate,qi.enddate as 
> vQIEndDate from cm_quotainstance as qi, cm_quota as q, fs_agr as a 
> where a.fs_unid = AGR_UNID and a.fs_model = q.model and qi.quota = 
> q.tril_gid LOOP
>
>                        if (vQIStartDate > M_COMM_CLOSE_DATE OR 
> vQIEndDate <= M_COMM_CLOSE_DATE) then
>                update  cm_quotainstance set changedate = 
> DEFAULT_LOWEST_DATE where tril_gid = vQuotaInstanceGID;
>                end if;
>        END LOOP;
>


for1 is a record type from which you can access the other columns. So 
with something like

FOR for1 in select * from cm_quotainstance where ... loop

then you can access the columns in your subsequent if statements like:

if (for1.startdate > > M_COMM_CLOSE_DATE OR for1.enddate <= 
M_COMM_CLOSE_DATE) ...

Look in the plpgsql section of the documentation under "Looping Through 
Query Results" -- this is section 36.7.4 in the 8.0 documentation.


Best,

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


In response to

pgsql-general by date

Next:From: Marek LewczukDate: 2004-12-27 19:54:49
Subject: Re: Get current trasanction id
Previous:From: Bruce MomjianDate: 2004-12-27 18:23:45
Subject: Re: 8.0 rc2 Problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group