[Geoserver-users] Create SQL View - "Table or biew does not exist"?

Hi List,
I’ve come across something weird and wondered if anyone could help.

I’m creating a new SQL view. The query:

select * from TRO_ORDERS where DATE_FROM <= %from_date% and (DATE_TO >= %to_date% or DATE_TO is null)


With the “SQL view parameters” filled in correctly, I then press “refresh” for it to load the attributes, but I get an Oracle error:

“ORA-00942: table or view does not exist”

However that table does exist. If I take the SQL generated from the logs and put it directly into SQL Developer, it works fine with no error but I get no results.

The SQL from the logs is:

select * from (select * from TRO_ORDERS where DATE_FROM <= 20130102 and (DATE_TO >= 20130102 or DATE_TO is null)) VTABLE where 1 = 0

If I trim this down (removing the stuff that GeoServe rappears to have added) to:

select * from TRO_ORDERS where DATE_FROM <= 20100102 and (DATE_TO >= 20100102 or DATE_TO is null)

That works and does return results.

Can anyone advise what’s going on? GeoServer can add the TRO_ORDERS layer just fine as a regular layer, so I’m not sure why it is having issues as a SQL View.

I’ve had a similar SQL view working previously too, so I know it can work.

Thanks,
Jonathan

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

Figured it out. Turns out GeoServer doesn’t add the schema for Oracle SQL Views. Created a JIRA issue for it as it seems inconsistent (the schema has to be in the store declaration).
http://jira.codehaus.org/browse/GEOS-6084

Seems more like it might be a design decision than an outright bug, but reported anyway just in case. :slight_smile:

Jonathan

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

···

On 11 October 2013 12:49, Jonathan Moules <jonathanmoules@anonymised.com> wrote:

Hi List,
I’ve come across something weird and wondered if anyone could help.

I’m creating a new SQL view. The query:

select * from TRO_ORDERS where DATE_FROM <= %from_date% and (DATE_TO >= %to_date% or DATE_TO is null)


With the “SQL view parameters” filled in correctly, I then press “refresh” for it to load the attributes, but I get an Oracle error:

“ORA-00942: table or view does not exist”

However that table does exist. If I take the SQL generated from the logs and put it directly into SQL Developer, it works fine with no error but I get no results.

The SQL from the logs is:

select * from (select * from TRO_ORDERS where DATE_FROM <= 20130102 and (DATE_TO >= 20130102 or DATE_TO is null)) VTABLE where 1 = 0

If I trim this down (removing the stuff that GeoServe rappears to have added) to:

select * from TRO_ORDERS where DATE_FROM <= 20100102 and (DATE_TO >= 20100102 or DATE_TO is null)

That works and does return results.

Can anyone advise what’s going on? GeoServer can add the TRO_ORDERS layer just fine as a regular layer, so I’m not sure why it is having issues as a SQL View.

I’ve had a similar SQL view working previously too, so I know it can work.

Thanks,
Jonathan

Hi Jonathan

Maybe you have a problem with the schema name. Normally, a table name consists of two parts, .. If you omit the schema name, a default is used (depends on the database, for DB2 this is the current user name).

···

On Fri, Oct 11, 2013 at 1:49 PM, Jonathan Moules <jonathanmoules@anonymised.com> wrote:

Hi List,
I’ve come across something weird and wondered if anyone could help.

I’m creating a new SQL view. The query:

select * from TRO_ORDERS where DATE_FROM <= %from_date% and (DATE_TO >= %to_date% or DATE_TO is null)


With the “SQL view parameters” filled in correctly, I then press “refresh” for it to load the attributes, but I get an Oracle error:

“ORA-00942: table or view does not exist”

However that table does exist. If I take the SQL generated from the logs and put it directly into SQL Developer, it works fine with no error but I get no results.

The SQL from the logs is:

select * from (select * from TRO_ORDERS where DATE_FROM <= 20130102 and (DATE_TO >= 20130102 or DATE_TO is null)) VTABLE where 1 = 0

If I trim this down (removing the stuff that GeoServe rappears to have added) to:

select * from TRO_ORDERS where DATE_FROM <= 20100102 and (DATE_TO >= 20100102 or DATE_TO is null)

That works and does return results.

Can anyone advise what’s going on? GeoServer can add the TRO_ORDERS layer just fine as a regular layer, so I’m not sure why it is having issues as a SQL View.

I’ve had a similar SQL view working previously too, so I know it can work.

Thanks,
Jonathan

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

DI Christian Mueller MSc (GIS), MSc (IT-Security)
OSS Open Source Solutions GmbH

Hi Christian,
Thanks, we seem to have crossed emails, but that was the conclusion in the end. It seems GeoServer doesn’t prefix the specified schema name to Oracle SQL Views.

Cheers,
Jonathan

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

···

On 11 October 2013 13:10, Christian Mueller <christian.mueller@anonymised.com> wrote:

Hi Jonathan

Maybe you have a problem with the schema name. Normally, a table name consists of two parts, .. If you omit the schema name, a default is used (depends on the database, for DB2 this is the current user name).

On Fri, Oct 11, 2013 at 1:49 PM, Jonathan Moules <jonathanmoules@anonymised.com> wrote:

Hi List,
I’ve come across something weird and wondered if anyone could help.

I’m creating a new SQL view. The query:

select * from TRO_ORDERS where DATE_FROM <= %from_date% and (DATE_TO >= %to_date% or DATE_TO is null)


With the “SQL view parameters” filled in correctly, I then press “refresh” for it to load the attributes, but I get an Oracle error:

“ORA-00942: table or view does not exist”

However that table does exist. If I take the SQL generated from the logs and put it directly into SQL Developer, it works fine with no error but I get no results.

The SQL from the logs is:

select * from (select * from TRO_ORDERS where DATE_FROM <= 20130102 and (DATE_TO >= 20130102 or DATE_TO is null)) VTABLE where 1 = 0

If I trim this down (removing the stuff that GeoServe rappears to have added) to:

select * from TRO_ORDERS where DATE_FROM <= 20100102 and (DATE_TO >= 20100102 or DATE_TO is null)

That works and does return results.

Can anyone advise what’s going on? GeoServer can add the TRO_ORDERS layer just fine as a regular layer, so I’m not sure why it is having issues as a SQL View.

I’ve had a similar SQL view working previously too, so I know it can work.

Thanks,
Jonathan

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

DI Christian Mueller MSc (GIS), MSc (IT-Security)
OSS Open Source Solutions GmbH

On Fri, Oct 11, 2013 at 2:09 PM, Jonathan Moules <
jonathanmoules@anonymised.com> wrote:

Figured it out. Turns out GeoServer doesn't add the schema for Oracle SQL
Views. Created a JIRA issue for it as it seems inconsistent (the schema has
to be in the store declaration).
http://jira.codehaus.org/browse/GEOS-6084

Seems more like it might be a design decision than an outright bug, but
reported anyway just in case. :slight_smile:

Indeed, GeoServer does not interpret or modifies the sql you provide, it
uses it "as is" (minus the sql view params).
So, it's up to you to specify the necessary schema names in the sql

Cheers
Andrea

--

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more
information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

···

Hi Andrea,
But then surely as I’ve explicitly declared a schema in the Store that should be used? I guess expectations may be different between users, but that’s what I’d expect to happen. I don’t normally include the schema myself in any of my queries in any software I use - not even SQL Developer where I’ve entered raw SQL - it is always added transparently.
So I think there’s a case for doing so with GeoServer. Anyone else have an opinion?
Cheers,
Jonathan

On 11 October 2013 16:51, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Fri, Oct 11, 2013 at 2:09 PM, Jonathan Moules <jonathanmoules@anonymised.com> wrote:

Figured it out. Turns out GeoServer doesn’t add the schema for Oracle SQL Views. Created a JIRA issue for it as it seems inconsistent (the schema has to be in the store declaration).
http://jira.codehaus.org/browse/GEOS-6084

Seems more like it might be a design decision than an outright bug, but reported anyway just in case. :slight_smile:

Indeed, GeoServer does not interpret or modifies the sql you provide, it uses it “as is” (minus the sql view params).
So, it’s up to you to specify the necessary schema names in the sql

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Mon, Oct 14, 2013 at 1:45 PM, Jonathan Moules <
jonathanmoules@anonymised.com> wrote:

Hi Andrea,
But then surely as I've explicitly declared a schema in the Store that
should be used? I guess expectations may be different between users, but
that's what I'd expect to happen. I don't normally include the schema
myself in any of my queries in any software I use - not even SQL Developer
where I've entered raw SQL - it is always added transparently.

This is because these tools setup the "default schema" or "search path"
before giving you a sql
editor to play with.
GeoServer could do the same, it could be an extra sql that send to the
database when retrieving a connection from the pool.
Of course this would have a cost, it would result in an extra call to the
dbms, maybe we should limit it to sql views... and
not everybody would be happy to have it because of that.

Plus, as icing on the cake, setting the default schema uses db specific
sql, so one would have to setup all the dialects we have
with their own custom way of setting the schema (e.g., it's "set
search_path to 'schema'" for postgresql,
"ALTER SESSION SET CURRENT_SCHEMA=schema" for Oracle, and so on)

Cheers
Andrea

--

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more
information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------