Table of Contents Previous Section
Adding Stored Procedures
If your stored procedure is defined in the database at the time you create your model, you don't have to do anything to define it in your model. When you create a new model with EOModeler, the application reads stored procedure definitions from the database's data dictionary and stores them in the model's .eomodeld file. You can also add a stored procedure definition to an existing model.To add a stored procedure:
- Select the Stored Procedures icon in the tree view.
- Choose Property Add Stored Procedure.
- Specify a name and external name for the stored procedure.
Figure 38. Adding a Stored Procedure
Note: The Advanced Attribute Inspector isn't applicable to stored procedure arguments. As a result, you can't access it while editing a stored procedure argument.
To define and display the attributes of a stored procedure:
- Select the stored procedure in the tree view.
- Choose Property Add Argument.
- Specify the argument's characteristics in the Model Editor's table.
Alternatively, you can double-click the icon to the left of a stored procedure in the Model Editor's stored procedure table.
Minimally, you must provide values for the Name, Column, Direction, External Type, and Value Class characteristics.
The following table describes the characteristics you can set for a stored procedure argument.
For example, to add arguments for the Sybase stored procedure defined as:
create proc movie_by_date (@begin datetime, @end datetime) as begin select CATEGORY, DATE_RELEASED, LANGUAGE, MOVIE_ID, RATING, REVENUE, STUDIO_ID, TITLE from MOVIES where DATE_RELEASED > @begin and DATE_RELEASED < @end endyou would add an argument for @begin and @end with column names "begin" and "end", respectively.
Tip: If you're using Oracle, you can define a stored procedure to represent a function. Add an argument named "returnValue" and use the EOAdaptorChannel method returnValuesForLastStoredProcedureInvocation to get the function's result.
If the Framework invokes your stored procedure automatically, the argument names of a stored procedure must match the name of a corresponding EOAttribute object. For example, if you want to invoke a stored procedure whenever the Framework fetches a Movie object by its primary key, the stored procedure's argument names must correspond to the primary key attributes of the Movie entity. The following section discusses this requirement more thoroughly.
Table of Contents Next Section