diff -u modules/unixodbc.orig/dbase.c modules/unixodbc.new/dbase.c
--- modules/unixodbc.orig/dbase.c	2006-03-15 18:48:14.000000000 +0200
+++ modules/unixodbc.new/dbase.c	2006-03-15 18:48:20.000000000 +0200
@@ -42,6 +42,7 @@
 #include "db_mod.h"
 #include "dbase.h"
 
+#define SQL_PROC 
 #define SQL_BUF_LEN 65536
 
 static char sql_buf[SQL_BUF_LEN];
@@ -113,7 +114,7 @@
 	    }
 	}
 	ret=SQLExecDirect(CON_RESULT(_h),  (SQLCHAR*)_s, SQL_NTS);
-	if (!SQL_SUCCEEDED(ret))
+	if (ret != SQL_SUCCESS)
 	{
 		LOG(L_ERR, "SQLExecDirect <%s> Return value: %d\n", _s, ret);
 		extract_error("SQLExecDirect", CON_RESULT(_h), SQL_HANDLE_DBC);
@@ -158,6 +159,7 @@
 	return -1;
 }
 
+#ifndef SQL_PROC
 /*
  * Print list of values separated by comma
  */
@@ -188,6 +190,7 @@
 	}
 	return res;
 }
+#endif
 
 /*
  * Print where clause of SQL statement
@@ -236,6 +239,46 @@
 }
 
 /*
+ * Print procedure parameters
+ */
+static int print_proc_param(SQLHDBC* _c, char* _b, int _l, db_key_t* _k, db_val_t* _v, int _n, char *_p)
+{
+	int i;
+	int len = 0, ret;
+	int l;
+
+	if (!_c || !_b || !_l || !_k || !_v || !_n || !_p)
+	{
+		LOG(L_ERR, "print_proc_param: Invalid parameter value\n");
+		return -1;
+	}
+
+	for(i = 0; i < _n; i++)
+	{
+		ret = snprintf(_b + len, _l - len, "%s%s=", _p, _k[i]);
+		if (ret < 0 || ret >= (_l - len)) goto error;
+		len += ret;
+
+		l = _l - len;
+		val2str(_c, &(_v[i]), _b + len, &l);
+		len += l;
+		if (i != (_n - 1))
+		{
+			if ((_l - len) >= 1)
+			{
+				*(_b + len++) = ',';
+			}
+		}
+	}
+	return len;
+
+	error:
+	LOG(L_ERR, "print_proc_param: Error in snprintf\n");
+	return -1;
+}
+
+#ifndef SQL_PROC
+/*
  * Print set clause of update SQL statement
  */
 static int print_set(SQLHDBC* _c, char* _b, int _l, db_key_t* _k, db_val_t* _v, int _n)
@@ -273,6 +316,7 @@
 	LOG(L_ERR, "print_set: Error in snprintf\n");
 	return -1;
 }
+#endif
 
 /*
  * Initialize database module
@@ -516,6 +560,41 @@
  * _v: values of the keys
  * _n: number of key=value pairs
  */
+#ifdef SQL_PROC
+int db_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)
+{
+	int off, ret;
+
+	if ((!_h) || (!_k) || (!_v) || (!_n))
+	{
+		LOG(L_ERR, "db_insert: Invalid parameter value\n");
+		return -1;
+	}
+
+	ret = snprintf(sql_buf, SQL_BUF_LEN, "{call insert_%s (", CON_TABLE(_h));
+	if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
+	off = ret;
+
+	ret = print_proc_param(&CON_CONNECTION(_h), sql_buf + off, SQL_BUF_LEN - off, _k, _v, _n, "p_");
+	if (ret < 0) return -1;
+	off += ret;
+
+	*(sql_buf + off++) = ')';
+	*(sql_buf + off++) = '}';
+	*(sql_buf + off) = '\0';
+
+	if (submit_query(_h, sql_buf) < 0)
+	{
+		LOG(L_ERR, "db_insert: Error while submitting query\n");
+		return -2;
+	}
+	return 0;
+
+	error:
+	LOG(L_ERR, "db_insert: Error in snprintf\n");
+	return -1;
+}
+#else
 int db_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)
 {
 	int off, ret;
@@ -556,7 +635,7 @@
 	LOG(L_ERR, "db_insert: Error in snprintf\n");
 	return -1;
 }
-
+#endif /* SQL_PROC */
 /*
  * Delete a row from the specified table
  * _h: structure representing database connection
@@ -565,6 +644,43 @@
  * _v: values of the keys that must match
  * _n: number of key=value pairs
  */
+#ifdef SQL_PROC
+int db_delete(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n)
+{
+	int off, ret;
+
+	if (!_h)
+	{
+		LOG(L_ERR, "db_delete: Invalid parameter value\n");
+		return -1;
+	}
+
+	ret = snprintf(sql_buf, SQL_BUF_LEN, "{call delete_%s (", CON_TABLE(_h));
+	if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
+	off = ret;
+
+	if (_n)
+	{
+		ret = print_proc_param(&CON_CONNECTION(_h), sql_buf + off, SQL_BUF_LEN - off, _k, _v, _n, "p_");
+		if (ret < 0) return -1;
+		off += ret;
+	}
+
+	*(sql_buf + off++) = ')';
+        *(sql_buf + off++) = '}';
+	*(sql_buf + off) = '\0';
+	if (submit_query(_h, sql_buf) < 0)
+	{
+		LOG(L_ERR, "db_delete: Error while submitting query\n");
+		return -2;
+	}
+	return 0;
+
+	error:
+	LOG(L_ERR, "db_delete: Error in snprintf\n");
+	return -1;
+}
+#else
 int db_delete(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n)
 {
 	int off, ret;
@@ -602,6 +718,7 @@
 	LOG(L_ERR, "db_delete: Error in snprintf\n");
 	return -1;
 }
+#endif /* SQL_PROC */
 
 /*
  * Update some rows in the specified table
@@ -614,6 +731,51 @@
  * _n: number of key=value pairs
  * _un: number of columns to update
  */
+#ifdef SQL_PROC
+int db_update(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
+db_key_t* _uk, db_val_t* _uv, int _n, int _un)
+{
+	int off, ret;
+
+	if ((!_h) || (!_uk) || (!_uv) || (!_un))
+	{
+		LOG(L_ERR, "db_update: Invalid parameter value\n");
+		return -1;
+	}
+
+	ret = snprintf(sql_buf, SQL_BUF_LEN, "{call update_%s (", CON_TABLE(_h));
+	if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
+	off = ret;
+
+	ret = print_proc_param(&CON_CONNECTION(_h), sql_buf + off, SQL_BUF_LEN - off, _uk, _uv, _un, "p_");
+	if (ret < 0) return -1;
+	off += ret;
+
+	if (_n && _un)
+		*(sql_buf + off++) = ',';
+
+	if (_n)
+	{
+		ret = print_proc_param(&CON_CONNECTION(_h), sql_buf + off, SQL_BUF_LEN - off, _k, _v, _n, "pp_");
+		if (ret < 0) return -1;
+		off += ret;
+	}
+
+	*(sql_buf + off++) = ')';
+        *(sql_buf + off++) = '}';
+	*(sql_buf + off) = '\0';
+	if (submit_query(_h, sql_buf) < 0)
+	{
+		LOG(L_ERR, "db_update: Error while submitting query\n");
+		return -2;
+	}
+	return 0;
+
+	error:
+	LOG(L_ERR, "db_update: Error in snprintf\n");
+	return -1;
+}
+#else
 int db_update(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
 db_key_t* _uk, db_val_t* _uv, int _n, int _un)
 {
@@ -642,10 +804,9 @@
 		ret = print_where(&CON_CONNECTION(_h), sql_buf + off, SQL_BUF_LEN - off, _k, _o, _v, _n);
 		if (ret < 0) return -1;
 		off += ret;
-
-		*(sql_buf + off) = '\0';
 	}
 
+	*(sql_buf + off) = '\0';
 	if (submit_query(_h, sql_buf) < 0)
 	{
 		LOG(L_ERR, "db_update: Error while submitting query\n");
@@ -657,10 +818,46 @@
 	LOG(L_ERR, "db_update: Error in snprintf\n");
 	return -1;
 }
+#endif /* SQL_PROC */
 
 /*
  * Just like insert, but replace the row if it exists
  */
+#ifdef SQL_PROC
+int db_replace(db_con_t* handle, db_key_t* keys, db_val_t* vals, int n)
+{
+	int off, ret;
+
+	if (!handle || !keys || !vals)
+	{
+		LOG(L_ERR, "db_replace: Invalid parameter value\n");
+		return -1;
+	}
+
+	ret = snprintf(sql_buf, SQL_BUF_LEN, "{call replace_%s (", CON_TABLE(handle));
+	if (ret < 0 || ret >= SQL_BUF_LEN) goto error;
+	off = ret;
+
+	ret = print_proc_param(&CON_CONNECTION(handle), sql_buf + off, SQL_BUF_LEN - off, keys, vals, n, "p_");
+	if (ret < 0) return -1;
+	off += ret;
+
+	*(sql_buf + off++) = ')';
+        *(sql_buf + off++) = '}';
+	*(sql_buf + off) = '\0';
+
+	if (submit_query(handle, sql_buf) < 0)
+	{
+		LOG(L_ERR, "db_replace: Error while submitting query\n");
+		return -2;
+	}
+	return 0;
+
+	error:
+	LOG(L_ERR, "db_replace: Error in snprintf\n");
+	return -1;
+}
+#else
 int db_replace(db_con_t* handle, db_key_t* keys, db_val_t* vals, int n)
 {
 	int off, ret;
@@ -701,3 +898,4 @@
 	LOG(L_ERR, "db_replace: Error in snprintf\n");
 	return -1;
 }
+#endif /* SQL_PROC */
