From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Ramroth, Laurie" <Laurie(dot)Ramroth(at)nrel(dot)gov> |
Cc: | "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: SQL state 42601 FOR syntax error |
Date: | 2010-12-23 03:05:42 |
Message-ID: | 14344.1293073542@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
"Ramroth, Laurie" <Laurie(dot)Ramroth(at)nrel(dot)gov> writes:
> I get a FOR syntax error on the following code.
> FOR rowNum IN SELECT DISTINCT ON (vehicle_id) vehicle_id FROM normal.joined_points_speeds_orderedID LOOP
> EXECUTE 'CREATE TEMP TABLE vehiclePointData_'||rowNum|| 'AS SELECT * FROM normal.joined_points_speeds_orderedID WHERE joined_points_speeds_orderedID.vehicle_id='||rowNum;
> EXECUTE 'COPY vehiclePointData_'||rowNum||'TO D:/PSRC_Public_access/calculations_points_speeds/'||rowNum||'.csv delimiters '||','||' WITH CSV HEADER';
> END LOOP;
> The Error reads-
> ERROR: syntax error at or near "FOR"
> LINE 1: FOR rowNum IN (SELECT DISTINCT ON (vehicle_id) vehicle_id ...
You haven't provided us a lot of context, but I'm going to guess that
you are trying to execute this as just plain SQL. It's not SQL.
FOR is a construct in the plpgsql procedural language; so you need to
put this into a plpgsql function.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Mladen Gogala | 2010-12-23 13:42:40 | Re: Does Skype outage have anything to do with PostgreSQL? |
Previous Message | Shoaib Mir | 2010-12-23 00:56:05 | Re: Does Skype outage have anything to do with PostgreSQL? |