diff --git a/procedures/insertEntityProperty.sql b/procedures/insertEntityProperty.sql
index e0bf40aecb6d07a6ef8c6b86241b5a4d144aa78a..ee26c168612cacf93f19576e21e36d23ff4270ca 100644
--- a/procedures/insertEntityProperty.sql
+++ b/procedures/insertEntityProperty.sql
@@ -47,7 +47,7 @@ delimiter //
  *     The overridden name
  * DescOverride : TEXT
  *     The overridden description
- * DatatypeOverride : INT UNSIGNED
+ * DatatypeOverride : VARCHAR(255)
  *     The overridden datatype
  * Collection : VARCHAR(255)
  *     The overridden collection (only if DatatypeOverride is present).
@@ -64,7 +64,7 @@ CREATE PROCEDURE db_5_0.insertEntityProperty(
     in PropertyStatus VARCHAR(255),
     in NameOverride VARCHAR(255),
     in DescOverride TEXT,
-    in DatatypeOverride INT UNSIGNED,
+    in DatatypeOverride VARCHAR(255),
     in Collection VARCHAR(255),
     in PropertyIndex INT UNSIGNED)
 BEGIN
diff --git a/procedures/query/applyIDFilter.sql b/procedures/query/applyIDFilter.sql
index f35d5cdaf8da2353956e7d541cc4378391d7f49c..183a0f512d2973188cb3fa0893846f83e1a19fe1 100644
--- a/procedures/query/applyIDFilter.sql
+++ b/procedures/query/applyIDFilter.sql
@@ -92,7 +92,9 @@ IF targetSet IS NULL OR targetSet = sourceSet THEN
             "1=1",
             CONCAT("NOT EXISTS (SELECT 1 FROM entity_ids AS eids WHERE eids.id ",
                 o,
+                ' "',
                 EntityID,
+                '" ',
                 " AND eids.internal_id = `",
                 sourceSet,
                 "`.id)"
@@ -111,7 +113,9 @@ ELSEIF versioned AND sourceSet = "entities" THEN
             "1=1",
             CONCAT("eids.id ",
                 o,
-                EntityID
+                ' "',
+                EntityID,
+                '"'
             )),
         IF(aggVal IS NULL,
             "",
@@ -122,7 +126,9 @@ ELSEIF versioned AND sourceSet = "entities" THEN
             "1=1",
             CONCAT("eids.id ",
                 o,
-                EntityID
+                ' "',
+                EntityID,
+                '"'
             )),
         IF(aggVal IS NULL,
             "",
@@ -143,7 +149,10 @@ ELSE
             "1=1",
             CONCAT("eids.id",
                 o,
-                EntityID)),
+                ' "',
+                EntityID,
+                '"'
+            )),
         IF(aggVal IS NULL,
             "",
             CONCAT(" AND data.id=",
diff --git a/procedures/query/initSubEntity.sql b/procedures/query/initSubEntity.sql
index e548250911ad596be4b632576393aa45410d450b..6bddd134fab294e8e5d093889fd77ffc4dba522e 100644
--- a/procedures/query/initSubEntity.sql
+++ b/procedures/query/initSubEntity.sql
@@ -60,9 +60,10 @@ BEGIN
     DEALLOCATE PREPARE stmt;
 
     IF EntityID IS NOT NULL THEN
-        SET @stmtStr = CONCAT('INSERT IGNORE INTO `', tableName, '` (id) SELECT internal_id FROM entity_ids WHERE id = ', EntityID, '');
+        SET @stmtStr = CONCAT('INSERT IGNORE INTO `', tableName, '` (id) SELECT internal_id FROM entity_ids WHERE id = ?');
         PREPARE stmt FROM @stmtStr;
-        EXECUTE stmt;
+        SET @eid = EntityID;
+        EXECUTE stmt USING @eid;
         SET ecount = ecount + ROW_COUNT();
         DEALLOCATE PREPARE stmt;
     END IF;