<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EstiloCorreioElectrnico17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=PT link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi again.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>I am trying to determine why I cannot get any sql queries to work against oracle and through arcsde driver.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>It seems the sql sentence keeps adding single-quotes to both field and value, which is not valid.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>For instance, a simple numeric clause:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Ogrinfo -so -ro -al -sql "SELECT * FROM ‘USER.TABLE’ WHERE FEATID=1234” “SDE:<connection string>”<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Results in errors being reported in the client:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>“(…)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> using driver `SDE' successful.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Layer name: GDBMAN.SREGA_PERIMETROS_REGA<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Geometry: Unknown (any)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>ERROR 1: SE_stream_fetch: -51/Underlying DBMS error<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Feature Count: -1<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>OGR_SDE: Loading GDBMAN.SREGA_PERIMETROS_REGA layerinfo.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>ERROR 1: SE_stream_fetch: -51/Underlying DBMS error<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Layer SRS WKT:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>(…)”<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>In ArcSDE logs I can see this sql query being reported:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>WhereClause: "('OBJECTID_1') = (21522)"<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Which in turn raises an error in Oracle, since single-quotes are meant for values and not for field names. For field names oracle allows double-quotes. So it should really be: (“OBJECTID_2”)=(21522).<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Then I tried a string query. And that doesn’t work either… I can’t figure out how to build a sql where clause in ogr with a string field that works…<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>So, has anyone any successful experience with ogr –sql queries in Oracle or ArcSDE? Any tips? I’m not sure where the error happens, either in sde driver or ogr sql parser…<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Duarte<o:p></o:p></span></p></div></body></html>