From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | neil(dot)saunders(at)accenture(dot)com |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Problem calling stored procedure |
Date: | 2005-08-23 14:06:55 |
Message-ID: | 2023.1124806015@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
<neil(dot)saunders(at)accenture(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Szűcs Gábor | 2005-08-23 15:09:42 | Tuple insert missing query in ongoing transaction |
Previous Message | neil.saunders | 2005-08-23 09:33:40 | Re: Problem calling stored procedure |