aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar aldot <aldot@5e8054f6-fb45-0410-9d17-f830fe724320>2009-04-21 11:43:16 +0000
committerGravatar aldot <aldot@5e8054f6-fb45-0410-9d17-f830fe724320>2009-04-21 11:43:16 +0000
commita9581d54d6c76629eadc9220d2edd66540cf694d (patch)
tree515cca35c6e80677c3ef15ada39e6695d0b4d1fc
parent2d019596e7006953ecac5f44bcde7797bdb9c9b6 (diff)
downloadndoutils-oracle-a9581d54d6c76629eadc9220d2edd66540cf694d.tar.gz
ndoutils-oracle-a9581d54d6c76629eadc9220d2edd66540cf694d.tar.bz2
- add ora_oci_get_rowcount() for informational purposes
git-svn-id: https://www.nagiosforge.org/svn/ndoutils_oracle/trunk/ndoutils-1.4b7-oracle@89 5e8054f6-fb45-0410-9d17-f830fe724320
-rw-r--r--liboci/include/liboci.h2
-rw-r--r--liboci/src/liboci.c22
2 files changed, 23 insertions, 1 deletions
diff --git a/liboci/include/liboci.h b/liboci/include/liboci.h
index f9332cf..d924624 100644
--- a/liboci/include/liboci.h
+++ b/liboci/include/liboci.h
@@ -32,5 +32,5 @@ int ora_oci_disconnect(void);
char *ora_oci_error(void);
sword checkerr(OCIError *errhp, sword status);
int ora_oci_prepare_statements(void);
-
+unsigned long ora_oci_get_rowcount(unsigned long instance, char *table_name);
#endif
diff --git a/liboci/src/liboci.c b/liboci/src/liboci.c
index 510a436..976adc2 100644
--- a/liboci/src/liboci.c
+++ b/liboci/src/liboci.c
@@ -456,6 +456,28 @@ unsigned long ora_oci_insert_id(void)
return insert_id;
}
+unsigned long ora_oci_get_rowcount(unsigned long instance, char *table_name)
+{
+ void **ii;
+ int i;
+ char *query;
+
+ asprintf(&query, "SELECT COUNT(*) FROM %s WHERE instance_id=%lu",
+ table_name, instance);
+ i = ora_oci_select(query);
+ free(query);
+ ii = ora_oci_fetch_row(p_sql);
+ if (ii == NULL) {
+ i = checkerr(p_err, i);
+ ndo2db_log("Fatal error: no rowcount! %s", ora_oci_error());
+ _exit(1);
+ }
+ i = *(unsigned long *) ii[0];
+ /* *(unsigned long *)idi->dbinfo.oracle_row[0] */
+ ora_oci_free_result(p_sql);
+ return i;
+}
+
/* Setup one statement's parameter bindings.
* Returns OCI_SUCCESS (0) on success, an OCI ERROR code otherwise.
*/