I see you have been busy discussing how to handle column names which contain 
dot "."
My problem is that I can't get any reasonable values from the query I make, 
whether I use "str1.str2" or 'str1.str2' in my expression.

In my C++ code this is:
a) const char *sSqlQuery = "SELECT \"str1.str2\" FROM 'layers:layer1'\"
b) const char *sSqlQuery = "SELECT 'str1.str2' FROM 'layers:layer1'\"

The result is the same, and I get no errors, but the column name returned to me 
is FIELD_1, and all values are str1.str2
What am I missing here?

When I run an ordinary query like:
const char *sSqlQuery = "SELECT \"str\" FROM 'layers:layer1'\"
then I get the correct result.

I've debugged a bit and found that 
OGRGenSQLResultsLayer::OGRGenSQLResultsLayer(), in ogr_gensql.cpp, generates 
the FIELD_1 name:
if( strlen(psColDef->field_name) == 0 )
        {
            CPLFree( psColDef->field_name );
            psColDef->field_name = (char *) CPLMalloc(40);
            sprintf( psColDef->field_name, "FIELD_%d", iField+1 );
        }

Please help, or confirm if I'm trying to do something illegal

>Odd-Ragnar<

-----Original Message-----
From: Even Rouault [mailto:[email protected]] 
Sent: 5. oktober 2012 18:39
To: Rahkonen Jukka
Cc: [email protected]
Subject: Re: [gdal-dev] OGR SQL: Excecuting select where column name contains 
"."

> To follow SQL, it is recommended to you double-quote characters,
> > which might require SHELL escaping since they are already in a
> double-quoted
> > string, like :
>

> Yes, that's a good theory but it is not easy to use it on Windows. 
> Does anybody in the world know how should this one be escaped? I have 
> already tried to use ^" as inner double quotes but without success, as 
> well as having two ^^ and three ^^^.

Doh! my webmail client has changed what I have typed ! To escape double-quote 
in Windows shell, you need to put a backslash character before them.

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to