diff --git a/lib/private/db/connection.php b/lib/private/db/connection.php
index a961c84f372da669e7cbdd5908a9378bacf9a73d..6c4f518dfb58f0f47f1933b105096d55f6958209 100644
--- a/lib/private/db/connection.php
+++ b/lib/private/db/connection.php
@@ -284,7 +284,9 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection {
 			$whereValues = array_merge($keys, $updatePreconditionValues);
 			foreach ($whereValues as $name => $value) {
 				$where->add($updateQb->expr()->eq(
-					$name, $updateQb->createNamedParameter($value, $this->getType($value))
+					$name,
+					$updateQb->createNamedParameter($value, $this->getType($value)),
+					$this->getType($value)
 				));
 			}
 			$updateQb->where($where);
diff --git a/lib/private/db/querybuilder/expressionbuilder.php b/lib/private/db/querybuilder/expressionbuilder.php
index de10f69b3613cb21f04ac7063c6eb021ece2b61a..1e86db5a081569318daec3568a1a80341a4836e6 100644
--- a/lib/private/db/querybuilder/expressionbuilder.php
+++ b/lib/private/db/querybuilder/expressionbuilder.php
@@ -27,10 +27,10 @@ use OCP\IDBConnection;
 
 class ExpressionBuilder implements IExpressionBuilder {
 	/** @var \Doctrine\DBAL\Query\Expression\ExpressionBuilder */
-	private $expressionBuilder;
+	protected $expressionBuilder;
 
 	/** @var QuoteHelper */
-	private $helper;
+	protected $helper;
 
 	/**
 	 * Initializes a new <tt>ExpressionBuilder</tt>.
@@ -109,10 +109,12 @@ class ExpressionBuilder implements IExpressionBuilder {
 	 *
 	 * @param mixed $x The left expression.
 	 * @param mixed $y The right expression.
+	 * @param int|null $type one of the \PDO::PARAM_* constants
+	 *                  required when comparing text fields for oci compatibility
 	 *
 	 * @return string
 	 */
-	public function eq($x, $y) {
+	public function eq($x, $y, $type = null) {
 		$x = $this->helper->quoteColumnName($x);
 		$y = $this->helper->quoteColumnName($y);
 		return $this->expressionBuilder->eq($x, $y);
diff --git a/lib/private/db/querybuilder/ociexpressionbuilder.php b/lib/private/db/querybuilder/ociexpressionbuilder.php
new file mode 100644
index 0000000000000000000000000000000000000000..742611bf7194421d80d3e46cad2f940b031015ea
--- /dev/null
+++ b/lib/private/db/querybuilder/ociexpressionbuilder.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\DB\QueryBuilder;
+
+class OCIExpressionBuilder extends ExpressionBuilder {
+	public function eq($x, $y, $type = null) {
+		$x = $this->helper->quoteColumnName($x);
+		$y = $this->helper->quoteColumnName($y);
+		if ($type === \PDO::PARAM_STR) {
+			$x = new QueryFunction('to_char(' . $x . ')');
+		}
+		return $this->expressionBuilder->eq($x, $y);
+	}
+}
diff --git a/lib/private/db/querybuilder/querybuilder.php b/lib/private/db/querybuilder/querybuilder.php
index 492e9bc9abf41bbf280852b0dbb33d97553ec5b5..42b290b90e762c1491f14ca603059b23536476ac 100644
--- a/lib/private/db/querybuilder/querybuilder.php
+++ b/lib/private/db/querybuilder/querybuilder.php
@@ -21,6 +21,7 @@
 
 namespace OC\DB\QueryBuilder;
 
+use OC\DB\OracleConnection;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\DB\QueryBuilder\IQueryFunction;
 use OCP\DB\QueryBuilder\IParameter;
@@ -82,7 +83,11 @@ class QueryBuilder implements IQueryBuilder {
 	 * @return \OCP\DB\QueryBuilder\IExpressionBuilder
 	 */
 	public function expr() {
-		return new ExpressionBuilder($this->connection);
+		if ($this->connection instanceof OracleConnection) {
+			return new OCIExpressionBuilder($this->connection);
+		} else {
+			return new ExpressionBuilder($this->connection);
+		}
 	}
 
 	/**
diff --git a/lib/public/db/querybuilder/iexpressionbuilder.php b/lib/public/db/querybuilder/iexpressionbuilder.php
index ae62694fcaf95c783339b3b6d4f783ece5785036..0549d3f0125e4282b5d4044c9bc262676b6912f1 100644
--- a/lib/public/db/querybuilder/iexpressionbuilder.php
+++ b/lib/public/db/querybuilder/iexpressionbuilder.php
@@ -84,11 +84,13 @@ interface IExpressionBuilder {
 	 *
 	 * @param mixed $x The left expression.
 	 * @param mixed $y The right expression.
+	 * @param int|null $type @since 9.0.0 one of the \PDO::PARAM_* constants
+	 *                  required when comparing text fields for oci compatibility.
 	 *
 	 * @return string
 	 * @since 8.2.0
 	 */
-	public function eq($x, $y);
+	public function eq($x, $y, $type = null);
 
 	/**
 	 * Creates a non equality comparison expression with the given arguments.