Re: Problem calling stored procedure

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Problem calling stored procedure
Дата
Msg-id 2023.1124806015@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Problem calling stored procedure  (<neil.saunders@accenture.com>)
Список pgsql-sql
<neil.saunders@accenture.com> writes:
> OPEN cur_overlap FOR SELECT *, pg_class.RELNAME AS table FROM calendar_entries WHERE (start_date, end_date) OVERLAP
(new_start_date,new_end_date) AND property_id = X AND pg_class.oid = tableoid;
 

> The only thing I can think of is that when the query runs in the psql I get:
> NOTICE: added missing FROM-clause entry for table "pg_class"

> I understand why this is happening, but don't know how I would go
> about re-writing the query to explicitly reference pg_class - I can't
> write calendar_entries.table_oid, because that changes the meaning of
> the query.

How so?  It'd be the same as far as I can see.

However, you could avoid any explicit use of pg_class by using the
regclass type instead:

OPEN cur_overlap FOR SELECT *, tableoid::regclass AS table FROM calendar_entries WHERE (start_date, end_date) OVERLAP
(new_start_date,new_end_date) AND property_id = X;
 

As far as the reason for the difference between function execution and
manual execution: check for unintended variable substitutions.  Which
words in the query match variable names in the plpgsql function?  Are
those only the ones you intended?
        regards, tom lane


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

Предыдущее
От:
Дата:
Сообщение: Re: Problem calling stored procedure
Следующее
От: Szűcs Gábor
Дата:
Сообщение: Tuple insert missing query in ongoing transaction