/* ** Aufruf PL/SQL - Stored Procedure */ #include #include using namespace oracle::occi; using namespace std; int main (void) { int RowCount; string inout, out; //Environment und Connection erzeugen Environment* env = Environment::createEnvironment(); Connection* conn = env->createConnection( "scott", "tiger", "cornel" ); cout << "Environment und Connection erzeugt" << endl; //SQL-Statement erzeugen Statement* stmt = conn->createStatement(); cout << "Statement erzeugt" << endl; try { stmt->setSQL("BEGIN cpp_plsql_proc(:v1, :v2, :v3); END;"); cout << "Ausführung von: " << stmt->getSQL() << endl; cout << "Eingabeparameter: v1 = 10, v2 = Kekse" << endl; //Parameter 1, IN, NUMBER stmt->setInt (1, 10); //Parameter 2, IN OUT, VARCHAR2 stmt->setMaxParamSize (2, 30); stmt->setString (2, "Kekse"); //Parameter 3, OUT, VARCHAR2 stmt->registerOutParam (3, OCCISTRING, 30, ""); //PL/SQL-Procedure aufrufen RowCount = stmt->executeUpdate (); cout << "RowCount:" << RowCount << endl; //Rueckgabewert (OUT) aus Parameter 2 und 3 holen inout = stmt->getString (2); out = stmt->getString (3); cout << "Rueckgabewerte der PL/SQL-Prozedur:" << endl; cout << "Parameter 2 (IN OUT): " << inout << endl; cout << "Parameter 3 (OUT): " << out << endl; } catch(SQLException ex) { cout << "Error number: " << ex.getErrorCode() << endl; cout << ex.getMessage() << endl; } conn->terminateStatement(stmt); cout << "Statement beendet" << endl; //Environment und Connection beenden env->terminateConnection(conn); Environment::terminateEnvironment(env); cout << "Environment und Connection beendet" << endl; }