Re: passing tables name into a cursor

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: passing tables name into a cursor
Дата
Msg-id CAHyXU0xBzFQxyKFKi0M6f8HYE0+GixYGkJ1OqdhpU7e9DHRM9Q@mail.gmail.com
обсуждение исходный текст
Ответ на passing tables name into a cursor  (John Kelly <jtkells@gmail.com>)
Список pgsql-general
On Mon, Nov 25, 2013 at 11:43 AM, John Kelly <jtkells@gmail.com> wrote:
> Im having a problem changing several cursors in a function to use a passed
> in child table name.  Database is 8.4.3 on Linux
> --Original cursor
>
> c_runway18a cursor is
>
> ( select id, geom
>         , way_num as waydesignator, status_d as status
>         , t_width as width
>         , t_len as length
> , coalesce(type_d,'X') as type
>   from v_features
> where f_type = ' || feature_type  and transaction_id = ' || id );
>
>
> -- Modified cursor
>
> SQL_18a text :='select id '
>           || ' , geom '
> || ' , way_num as waydesignator '
> || ' , status_d as status '
> || ' , t_width as width '
> || ' , t_len as length '
> || ' , coalesce(type_d,''X'') as type '
> || ' from ' ||v_features_child
>    --the table is a child table, so I have to passed in to the function so
> it will use indexes
> || ' where f_type = ' || feature_type
> || ' and transaction_id = ' || id ;
>
>
>  c_18a cursor is execute SQL_18a ;
> --  this works on 9.1 Windows, but when I compile it on a 8.4.3 system I get
> the following error
>
> psql:val_ways.sql:756: ERROR:  syntax error at or near ":"
> LINE 1:  execute $1
>                  ^
> QUERY:   execute $1
> CONTEXT:  SQL statement in PL/PgSQL function "val_ways" near line 26
>
> I have tried  "c_18a cursor is SQL_18a" without the execute clause, with
> single quotes and ':' and get the same general error "QUERY:  $1" .
> Any thoughts?


Problem is in the EXECUTE statement, not in the query being executed.
My guess is you are relying on some feature that is not present in
8.4.  Can we see the complete execute statement?

merlin


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

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: wiki on monitoring locks has queries that don't seem to work
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: wiki on monitoring locks has queries that don't seem to work