SQL state 42601 FOR syntax error

Поиск
Список
Период
Сортировка
От Ramroth, Laurie
Тема SQL state 42601 FOR syntax error
Дата
Msg-id 9700A92FD044934E8E64B214D8B0F38C1C1B0BDA55@MAILBOX1.nrel.gov
обсуждение исходный текст
Ответы Re: SQL state 42601 FOR syntax error  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice

Sir/Madam:

 

The code that follows iterates on a temporary table of distinct vehicle id’s that results from a query on the normal.joined_points_speeds_orderedID table.  The normal.joined_points_speeds_orderedid table has vehicle_id, trip_id, local_ts, calc_miles_duration, calc_time_duration, and calc_speed fields and is ordered by vehicle_id. The purpose of this code is to break up a large table of point level vehicle data by vehicle_id (into several smaller tables stored as csv).  I think the code that follows should do this by copying temporary tables into csv files, however it doesn’t.  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 …

 

********Error**********

ERROR: syntax error at or near “FOR”

SQL state: 42601

Character: 1

 

Can you spot the error in the included code?

 

Thank you.

 

Laurie Ramroth

 

В списке pgsql-novice по дате отправления:

Предыдущее
От: Frank Bax
Дата:
Сообщение: Re: Does Skype outage have anything to do with PostgreSQL?
Следующее
От: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
Дата:
Сообщение: Re: pg_largeobject and toast