Обсуждение: missing FROM-clause entry for table bbbb

Поиск
Список
Период
Сортировка

missing FROM-clause entry for table bbbb

От
Abhra Kar
Дата:
Hi 
 I tried to modify below sql command in postgres syntax--- 
 
 insert into aaaa (id, groupid, ele_id, ro_element_id) ")
             select bbbb.nextval, :groupid, gosp.neteleid, gosp.hodev 
       from net_ele gos, net_gos_prop gosp "
           where gos.eid in ( :eids ) and gos.id = gosp.net_element_id and 
            gos.id not in (select ealjs.element_id from aaaa ealjs where ealjs.groupid = :groupid)

If I run this it gives error for ":".If I remove : then I will get error like  missing FROM-clause entry for table bbbb.

What is the issue here and what should be exact query in postgressql

Thanks  

Re: missing FROM-clause entry for table bbbb

От
"David G. Johnston"
Дата:
You should pick one list to post to.

On Tue, Jan 16, 2018 at 4:36 AM, Abhra Kar <abhra.kar@gmail.com> wrote:
Hi 
 I tried to modify below sql command in postgres syntax--- 
 
 insert into aaaa (id, groupid, ele_id, ro_element_id) ")

​That ") looks wrong...​

             select bbbb.nextval, :groupid, gosp.neteleid, gosp.hodev 
       from net_ele gos, net_gos_prop gosp "

​As does that "
           where gos.eid in ( :eids ) and gos.id = gosp.net_element_id and 
            gos.id not in (select ealjs.element_id from aaaa ealjs where ealjs.groupid = :groupid)

If I run this it gives error for ":".If I remove : then I will get error like  missing FROM-clause entry for table bbbb.


​How are you executing the query, in what client program.  If it is ​psql did you define the variable groupid and eids prior to running the provided query?

What is the issue here and what should be exact query in postgressql


​PostgreSQL

You should provide the exact and complete psql script you are trying to run ... asking for help with an incomplete example won't get you far.

David J.

Re: missing FROM-clause entry for table bbbb

От
"David G. Johnston"
Дата:
You should pick one list to post to.

On Tue, Jan 16, 2018 at 4:36 AM, Abhra Kar <abhra.kar@gmail.com> wrote:
Hi 
 I tried to modify below sql command in postgres syntax--- 
 
 insert into aaaa (id, groupid, ele_id, ro_element_id) ")

​That ") looks wrong...​

             select bbbb.nextval, :groupid, gosp.neteleid, gosp.hodev 
       from net_ele gos, net_gos_prop gosp "

​As does that "
           where gos.eid in ( :eids ) and gos.id = gosp.net_element_id and 
            gos.id not in (select ealjs.element_id from aaaa ealjs where ealjs.groupid = :groupid)

If I run this it gives error for ":".If I remove : then I will get error like  missing FROM-clause entry for table bbbb.


​How are you executing the query, in what client program.  If it is ​psql did you define the variable groupid and eids prior to running the provided query?

What is the issue here and what should be exact query in postgressql


​PostgreSQL

You should provide the exact and complete psql script you are trying to run ... asking for help with an incomplete example won't get you far.

David J.

Re: missing FROM-clause entry for table bbbb

От
David Rowley
Дата:
On 17 January 2018 at 00:36, Abhra Kar <abhra.kar@gmail.com> wrote:
>  insert into aaaa (id, groupid, ele_id, ro_element_id) ")
>              select bbbb.nextval, :groupid, gosp.neteleid, gosp.hodev
>        from net_ele gos, net_gos_prop gosp "
>            where gos.eid in ( :eids ) and gos.id = gosp.net_element_id and
>             gos.id not in (select ealjs.element_id from aaaa ealjs where
> ealjs.groupid = :groupid)
>
> If I run this it gives error for ":".If I remove : then I will get error
> like  missing FROM-clause entry for table bbbb.

bbbb.nextval looks like some sort of Oracle syntax to get the nextval
from a sequence. In PostgreSQL you'd do nextval('bbbb'); Assuming you
have a sequence named "bbbb"

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


Re: missing FROM-clause entry for table bbbb

От
David Rowley
Дата:
On 17 January 2018 at 00:36, Abhra Kar <abhra.kar@gmail.com> wrote:
>  insert into aaaa (id, groupid, ele_id, ro_element_id) ")
>              select bbbb.nextval, :groupid, gosp.neteleid, gosp.hodev
>        from net_ele gos, net_gos_prop gosp "
>            where gos.eid in ( :eids ) and gos.id = gosp.net_element_id and
>             gos.id not in (select ealjs.element_id from aaaa ealjs where
> ealjs.groupid = :groupid)
>
> If I run this it gives error for ":".If I remove : then I will get error
> like  missing FROM-clause entry for table bbbb.

bbbb.nextval looks like some sort of Oracle syntax to get the nextval
from a sequence. In PostgreSQL you'd do nextval('bbbb'); Assuming you
have a sequence named "bbbb"

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services