Jump to content

OCCI - Null pointer in Statement::execute()

Recommended Posts

I create a table with a custom type like this:

CREATE TABLE my_table (id_no NUMBER(5), my_col my_type);
INSERT INTO my_table VALUES (1, my_type(5,6,7));

In SQL Developer my query 

SELECT my_col FROM my_table;

yields "USER.MY_TYPE(5,6,7)", as expected.

Now I connect to the database with OCCI and use the same query. Here is my minimal code:

#include "occi.h";
#include <iostream>
int main()
	using namespace std;
	using namespace oracle::occi;
	try {
		Environment* env = Environment::createEnvironment();
		Connection* conn = env->createConnection("user", "123", "");
		Statement* stmt = conn->createStatement("select my_col from my_table");		
		Statement::Status status = stmt->execute();
	catch (SQLException &e) {
		cout << e.what();
	return 0;

But the execute() method crashes by reading from a null-pointer. No exception is thrown.

This happens only for selecting columns with custom types like VARRAY and OBJECT.

All pointers in my code are not null and oracommon12.dll (windows), where the violation comes from, provides no debug information to look inside stmt.

Am I doing something wrong here? How can I receive the data in my_col with OCCI?

I am using OCCI ver. 12.2.

Share this post

Link to post
Share on other sites

Hello Mr. Ganesan.

This works indeed.

After each call of ResultSet::next() I get a single element from ResultSet::getNumber().

Thank you very much.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now