Re: Need help with this Function. I'm getting an error

Поиск
Список
Период
Сортировка
От David G Johnston
Тема Re: Need help with this Function. I'm getting an error
Дата
Msg-id 1402523661447-5806894.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: Need help with this Function. I'm getting an error  (ssharma <sharma.shubhra07@gmail.com>)
Ответы Re: Need help with this Function. I'm getting an error  (ssharma <sharma.shubhra07@gmail.com>)
Список pgsql-novice
ssharma wrote
> I am able to run the query successfully outside of the function. I know
> the problem is with, per_inventory_query:= quote_literal((select
> A.company_name from
> fetch_cucm_systems()
> where A.id=sys_id ::bigint)) ;
> I was hoping somebody could eyeball the syntax and tell me why select *
> from bar()
> becomes select quote_literal((select
> A.company_name from
> fetch_cucm_systems()
> where A.id=sys_id ::bigint)) in my case ?

The query:

select A.company_name from fetch_cucm_systems() where A.id=sys_id::bigint;

The only FROM table name present is called "fetch_cucm_systems", it is the
same as the function name.  But you are trying to refer to table "A" here in
both the WHERE clause and the select list.

If you really want to call the function result table "A" you need to provide
an alias:

select A.company_name from fetch_cucm_systems() AS A where
A.id=sys_id::bigint;

That is the snippet of the SELECT reference page that I quoted to you - the
syntax for aliasing a FROM clause item.

I don't get what you mean by "select * from bar() becomes select
quote_literal [...]" ...

It would help, too, if you actually talked and not just throw up code.  If
you tell us what is confusing you we can provide better help.

David J.




--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Need-help-with-this-Function-I-m-getting-an-error-tp5806884p5806894.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.


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

Предыдущее
От: Markus Neumann
Дата:
Сообщение: Re: I probably don't understand aggregates.
Следующее
От: David G Johnston
Дата:
Сообщение: Re: I probably don't understand aggregates.