/*Method to execute sql statements like SELECT and return Cursor
Inputs:
query- string containing sql query
qlength - length of query (for binary data). if 0 then assume null terminated.
Output: NULL cursor on error
*/
DBCursor *DBConnection_ORACLE::sqlQuery(char *p_query, DBString *p_arguments, int p_argument_count, int p_rows)
{
	if (!isConnected)
		return NULL;

	Cda_Def *t_cursor;
	t_cursor = ExecuteQuery(p_query, p_arguments, p_argument_count);
	if (t_cursor == NULL)
		return NULL;

	DBCursor_ORACLE *t_rev_cursor;
	t_rev_cursor = new DBCursor_ORACLE();
	if (!t_rev_cursor -> open((DBConnection *)this, t_cursor, p_rows))
	{
		// OK-2007-09-10 : Bug 5360
		delete t_rev_cursor;
		t_rev_cursor = NULL;
		char t_error_message[512];
		oerhms((cda_def *)getLDA(), lda.rc, (text *)t_error_message, (sword) sizeof(t_error_message));
		errorMessageSet(t_error_message);
	}
	else
	{
		// OK-2007-09-10 : Bug 5360
		errorMessageSet(NULL);
		addCursor(t_rev_cursor);
	}

	lda . rc = t_cursor -> rc;

	return (DBCursor *)t_rev_cursor;
}
Exemple #2
0
static uschar *
oracle_error(struct cda_def *oracle_handle, int rc, uschar *msg)
{
uschar tmp[1024];
oerhms(oracle_handle, rc, tmp, sizeof(tmp));
return string_sprintf("ORACLE %s: %s", msg, tmp);
}
Exemple #3
0
char *DBCursor_ORACLE::getErrorMessage()
{
	if (ORACLE_res->rc != 0)
		oerhms(ORACLE_res, ORACLE_res->rc, (text *)errmsg, 
			(sword) sizeof(errmsg));
	return errmsg;
}
Bool DBConnection_ORACLE::connect(char **args, int numargs)
{
	if (isConnected)
		return True;
	
	// MW-2014-01-30: [[ Sqlite382 ]] Relaxed revdb_connect() so it only checks for at least
	//   one argument - we need at least 4 though.
	if (numargs < 4)
		return False;

	char *t_user;
	t_user = args[2];

	char *t_password;
	t_password = args[3];

	char *t_database;
	t_database = args[1];

	char *t_host;
	t_host = args[0];

	if (t_user[0] == '\0')
		t_user = NULL;

	if (t_password[0] == '\0')
		t_password = NULL;

	memset(hda,0,HDA_SIZE);

	sword t_error;
	t_error = olog(&lda, hda, (ub1 *)t_user, -1, (ub1 *)t_password, -1, (ub1 *)t_host, -1, OCI_LM_DEF);
	if (t_error != 0)
	{
		// OK-2010-02-24: Oracle connection should return an error message if it failed.
		// The 600 char buffer size was taken from example code on Oracle's site.
		char *t_error_message;
		t_error_message = (char *)malloc(600);
		oerhms(&lda, lda .rc, (OraText *)t_error_message, 600);
		m_error = t_error_message;

		return False;
	}

	connectionType = CT_ORACLE,
	isConnected = True;
	return True;
}
Exemple #5
0
static char *
ora_error(Cda_Def * cda)
{
	sword n, l;
	static text errmsg[ 512 ];

	n = oerhms(cda, cda->rc, errmsg, 400);

	/* remove the last newline */
	l = strlen(errmsg);
	if (l < 400 && errmsg[l - 1] == '\n') {
		errmsg[l - 1] = '\0';
		l--;
	}
	if (cda->fc > 0) {
		strcat(errmsg, " -- while processing OCI function ");
		strncat(errmsg, ora_func_tab[cda->fc], 75);  /* 512 - 400 - 36 */
	}
	return (char *) errmsg;
}
/*Method to execute quick and fast sql statements like UPDATE and INSERT
Inputs:
query- string containing sql query
qlength - length of query (for binary data). if 0 then assume null terminated.
affectedrows - will recieve number of rows updated or inserted
Output: False on error
*/
Bool DBConnection_ORACLE::sqlExecute(char *p_query, DBString *p_arguments, int p_argument_count, unsigned int &p_affected_rows)
{
	if (!isConnected)
		return False;

	Cda_Def *t_cursor;
	t_cursor = ExecuteQuery(p_query, p_arguments, p_argument_count);
	if (t_cursor == NULL)
	{
		// OK-2007-09-10 : Bug 5360
		char t_error_message[512];
		oerhms((cda_def *)getLDA(), lda.rc, (text *)t_error_message, (sword) sizeof(t_error_message));
		errorMessageSet(t_error_message);
		return False;
	}

	int t_affected_rows;
	t_affected_rows = (int)t_cursor -> rpc;
	p_affected_rows = t_affected_rows;

	oclose(t_cursor);
	errorMessageSet(NULL);
	return True;
}