refer to ODP.NET online help in the “Implicit
REF CURSOR Binding Support” section.)
Earlier you ran a script (HR_SP. SQL) that
created the UPDATE_AND_RETURN_SALARY
procedure and added it to the entity model.
This procedure accepts an employee ID and a
salary increase amount, and then it outputs
a REF CURSOR containing the employee’s
first name and the new salary.
To get your application ready to call the
first open the Model Designer, and then view
the Model Browser (see Figure 1). Under
HRModel.Store, click the Stored Procedures
node, and then right-click UPDATE_AND_
RETURN_SALARY. From the menu, choose
Add Function Import. In the Add Function
Import dialog box (see Figure 2), for Returns
a Collection Of, select Complex. Click Get
Column Information. The column information will be retrieved from the App. Config file.
To call the method from . NE T, you will use
the name listed in the Function Import Name
field (in this case, UPDATE_AND_RETURN_
SALARY). Click Create New Complex Type
and click OK. In the Model Browser, you will
now see UPDATE_AND_RETURN_SALARY
under HRModel.edmx -> EntityContainer:
HREntities -> Function Imports.
In your project’s program file, uncomment the next block of code—// CALLING
A STORED PROCEDURE VIA IMPORT
FUNCTION (RETURNING VALUES)—shown
in Listing 3. Build and step into it.
Take a look at the output window and
note that the employee’s first name and the
updated salary are displayed there.
Binding to stored procedure output values.
If you only need to return a single scalar
value, rather than a collection of complex
types, you can bypass the need to use
SYS_REFCURSORs and the resulting App
. Config configuration file by binding directly
to stored procedure parameter output values
in your code and allowing the imported function to simply return null.
Earlier you ran a script (HR_SP.SQL)
that created the UPDATE_AND_RE TURN_
SALARY_BINDV procedure and added it
to the entity model. The UPDATE_AND_
RETURN_SALARY_BINDV procedure accepts
an employee ID and a salary increase amount,
and it includes an output NUMBER parameter
Figure 1: Entity Data Model Designer
Figure 2: Add Function Import dialog box
ORACLE MAGAZINE SEP TEMBER/OC TOBER 2011