Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'po/odbc-update-delete-no-rows' into ccase/r13b04_dev

* po/odbc-update-delete-no-rows:
  SQL_NO_DATA and SQLSTATE 00000 indicate success for updates/deletes that affect no rows
  • Loading branch information...
commit 62718c973354c80ed6f568574790dec17e9787b8 2 parents ea35770 + 1a564f8
authored February 08, 2010

Showing 1 changed file with 22 additions and 14 deletions. Show diff stats Hide diff stats

  1. 36  lib/odbc/c_src/odbcserver.c
36  lib/odbc/c_src/odbcserver.c
... ...
@@ -1,19 +1,19 @@
1 1
 /*
2 2
  * %CopyrightBegin%
3  
- * 
4  
- * Copyright Ericsson AB 1999-2009. All Rights Reserved.
5  
- * 
  3
+ *
  4
+ * Copyright Ericsson AB 1999-2010. All Rights Reserved.
  5
+ *
6 6
  * The contents of this file are subject to the Erlang Public License,
7 7
  * Version 1.1, (the "License"); you may not use this file except in
8 8
  * compliance with the License. You should have received a copy of the
9 9
  * Erlang Public License along with this software. If not, it can be
10 10
  * retrieved online at http://www.erlang.org/.
11  
- * 
  11
+ *
12 12
  * Software distributed under the License is distributed on an "AS IS"
13 13
  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 14
  * the License for the specific language governing rights and limitations
15 15
  * under the License.
16  
- * 
  16
+ *
17 17
  * %CopyrightEnd%
18 18
  *
19 19
 
@@ -749,11 +749,12 @@ static db_result_msg db_param_query(byte *buffer, db_state *state)
749 749
     byte *sql; 
750 750
     db_result_msg msg; 
751 751
     int i, num_param_values, ver = 0,
752  
-	erl_type = 0, index = 0, size = 0, cols = 0; 
  752
+       erl_type = 0, index = 0, size = 0, cols = 0;
753 753
     long long_num_param_values;  
754 754
     param_status param_status;
755 755
     diagnos diagnos;
756  
-    param_array *params; 
  756
+    param_array *params;
  757
+    SQLRETURN result;
757 758
 
758 759
     if (associated_result_set(state)) {
759 760
 	clean_state(state);
@@ -784,10 +785,16 @@ static db_result_msg db_param_query(byte *buffer, db_state *state)
784 785
   				   num_param_values, state);  
785 786
     
786 787
     if(params != NULL) {
787  
-	if(!sql_success(SQLExecDirect(statement_handle(state),
788  
-				      sql, SQL_NTS))) {
789  
-	    diagnos = get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
790  
-	    msg = encode_error_message(diagnos.error_msg);
  788
+
  789
+	result = SQLExecDirect(statement_handle(state), sql, SQL_NTS);
  790
+	if (!sql_success(result) || result == SQL_NO_DATA) {
  791
+		diagnos = get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
  792
+	}
  793
+	/* SQL_NO_DATA and SQLSTATE 00000 indicate success for
  794
+	   updates/deletes that affect no rows */
  795
+	if(!sql_success(result) &&
  796
+	   !(result == SQL_NO_DATA && !strcmp((char *)diagnos.sqlState, INFO))) {
  797
+		msg = encode_error_message(diagnos.error_msg);
791 798
 	} else {
792 799
 	    for (i = 0; i < param_status.params_processed; i++) {
793 800
 		switch (param_status.param_status_array[i]) {
@@ -2452,6 +2459,7 @@ static diagnos get_diagnos(SQLSMALLINT handleType, SQLHANDLE handle)
2452 2459
     int acc_errmsg_size;
2453 2460
     byte *current_errmsg_pos;
2454 2461
     SQLCHAR current_sql_state[SQL_STATE_SIZE];
  2462
+    SQLRETURN result;
2455 2463
 
2456 2464
     diagnos.error_msg[0] = 0;
2457 2465
     
@@ -2464,10 +2472,10 @@ static diagnos get_diagnos(SQLSMALLINT handleType, SQLHANDLE handle)
2464 2472
     /* Foreach diagnostic record in the current set of diagnostic records
2465 2473
        the error message is obtained */
2466 2474
     for(record_nr = 1; ;record_nr++) {    
2467  
-	if(SQLGetDiagRec(handleType, handle, record_nr, current_sql_state,
  2475
+        result = SQLGetDiagRec(handleType, handle, record_nr, current_sql_state,
2468 2476
 			 &nativeError, current_errmsg_pos,
2469  
-			 (SQLSMALLINT)errmsg_buffer_size, &errmsg_size)
2470  
-	   != SQL_SUCCESS) {
  2477
+							   (SQLSMALLINT)errmsg_buffer_size, &errmsg_size);
  2478
+	if(result != SQL_SUCCESS && result != SQL_NO_DATA) {
2471 2479
 
2472 2480
       
2473 2481
 	    break;

0 notes on commit 62718c9

Please sign in to comment.
Something went wrong with that request. Please try again.