{
  "date": "2021-03-24T09:20:28",
  "slug": "ora-32635-not-a-single-cell-reference-predicate",
  "link": "https://www.dbi-services.com/blog/ora-32635-not-a-single-cell-reference-predicate/",
  "title": {
    "rendered": "ORA-32635: not a single cell reference predicate"
  },
  "content": {
    "rendered": "<h2>By Franck Pachot</h2>\n<p>.<br />\nI spent 30 minutes to try to understand this error with a query that I&#8217;ve run in many environments for years. So if you google it you may arrive here and the solution may be checking whether you have NLS_COMP=LINGUISTIC</p>\n<pre><code>\nSQL&gt; alter session set nls_comp=linguistic;\n\nSession altered.\n\nSQL&gt; alter session set nls_language=french;\n\nSession modifiee.\n\nSQL&gt; select * from (\n  2  select 42 snap_id,'TM' type,'DB time' name,0 microseconds from dual\n  3  ) model return updated rows\n  4    partition by (snap_id)\n  5    dimension by (type,name)\n  6    measures (microseconds) ( microseconds['','']=microseconds['TM','DB time'])\n  7  /\n  measures (microseconds) ( microseconds['','']=microseconds['TM','DB time'])\n                                                             *\nERREUR a la ligne 6 :\nORA-32635: ce n'est pas un predicat de reference de cellule unique\n\nSQL&gt; host oerr ora 32635\n\n32635, 00000, \"not a single cell reference predicate\"\n// *Cause: A predicate that is not a single cell reference predicate was specified\n//         where a single cell reference predicate was expected.\n//         A single cell reference predicate is either a constant expression\n//         or a predicate of the form \n// *Action: Make sure that the predicate is a proper single cell\n//          reference. In some cases, you might have to put explicit\n//          type conversion operators (or casts) on the constant expression.\n</code></pre>\n<p>This error message was not very clear to me. Of course the NLS parameters were set at instance level, so not immediately visible.<br />\nI had to reduce my long query to one similar to the one above (because initially I suspected duplicate values in the dimensions but I was wrong) and with one line. Given the misleading clue <em>&#8220;you might have to put explicit type conversion operators (or casts) on the constant expression&#8221;</em> (I tried to cast to CHAR first) I finally checked at NLS parameters.</p>\n<p>So now you have the solution:</p>\n<pre><code>\nSQL&gt; alter session set nls_comp=BINARY;\n\nSession modifiee.\n\nSQL&gt;\nSQL&gt; select * from (\n  2  select 42 snap_id,'TM' type,'DB time' name,0 microseconds from dual\n  3  ) model return updated rows\n  4    partition by (snap_id)\n  5    dimension by (type,name)\n  6    measures (microseconds) ( microseconds['','']=microseconds['TM','DB time'])\n  7  /\n\n   SNAP_ID TY NAME    MICROSECONDS\n---------- -- ------- ------------\n        42                       0\n</code></pre>\n<p>The linguistic comparison may not give a unique result depending on the character set, and that may be the cause for this message. With BINARY comparison (the default) there&#8217;s no problem.</p>\n<p>By the way, I was not surprised to find nothing in Google or MOS. I know that I may be the only one using the MODEL clause 😉 and database with such NLS settings are rare (hopefully).</p>\n",
    "protected": false
  }
}
