OCL allows you to call any stored procedure or function easily, including procedures and functions in packages. It is well enough to provide only the name of procedure. To execute stored procedure set command type to ctStoredProc before calling execute method. For example, to insert new record into DEPT table by calling DEPT_INSERT procedure:
CREATE OR REPLACE
PROCEDURE DEPT_INSERT (
p_DeptNo NUMBER,
p_DName VARCHAR2,
p_Loc VARCHAR2)
is
begin
INSERT INTO Scott.Dept(DeptNo, DName, Loc)
VALUES (p_DeptNo, p_DName, p_Loc);
end;
you can write this code:
OraConnection connection("scott/tiger@ora");
OraCommand cmd;
. . .
cmd.setConnection(connection);
cmd.createProcCall("DEPT_INSERT");
cmd.param("p_DeptNo").setInt(50);
cmd.param("p_DName").setString("DEVELOPMENT");
cmd.param("p_Loc").setString("LONDON");
cmd.execute();
If you call stored function you can access to its result by looking into parameter with the "Result" name.
OCL gives ability to fetch rows from REF CURSOR parameter. This feature is available with OraRecordset. To fetch records from the REF CURSOR parameter call executeQuery method that will return recordset for this cursor. At proc demo project you can find example of calling such procedure.