Browse Source

Fixed bug when inserting and retrieving the CURRVAL of the just entered record

spficklin 11 years ago
parent
commit
41b5014686
1 changed files with 2 additions and 2 deletions
  1. 2 2
      tripal_core/api/tripal_core_chado.api.inc

+ 2 - 2
tripal_core/api/tripal_core_chado.api.inc

@@ -347,7 +347,7 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
     if (array_key_exists('primary key', $table_desc) and is_array($table_desc['primary key'])) {
       foreach ($table_desc['primary key'] as $field) {
         $sql = '';
-        $psql = "PREPARE currval_" . $table . "_" . $field . " AS SELECT CURRVAL('" . $table . "_" . $field . "_seq')";
+        $psql = "PREPARE currval_" . $table . "_" . $field . " AS SELECT CURRVAL('{" . $table . "}_" . $field . "_seq')";
         $is_prepared = tripal_core_chado_prepare("currval_" . $table . "_" . $field, $psql, array());
         $value = '';
         if ($is_prepared) {
@@ -359,7 +359,7 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
           }
         }
         else {
-          $sql = "SELECT CURRVAL('" . $table . "_" . $field . "_seq')";
+          $sql = "SELECT CURRVAL('{" . $table . "}_" . $field . "_seq')";
           $value =  db_result(chado_query($sql));
           if (!$value) {
             watchdog('tripal_core', "tripal_core_chado_insert: not able to retrieve primary key after insert: %sql",