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