Calling a Oracle Stored Procedure/Function
Calling a Oracle Stored Procedure/Function
- Subject: Calling a Oracle Stored Procedure/Function
- From: meena <email@hidden>
- Date: Thu, 20 Feb 2003 13:46:09 +0100
Hello everybody,
I would like to get some help on how to call a oracle stored procedure /
stored function. I am using Webobjects 5.1.4.
I went through the article on the AppleCareKnowledgeBase
http://docs.info.apple.com/article.html?artnum=75290 which explains how
to configure an Oracle Stored Procedure in WebObjects 5.1
I was using a stored procedure in WebObjects 4.5. This article advices
to replace the oracle stored procedure as a stored function, when there
is a return value. Do we still have to replace the stored procedure
by a stored function, even if the procedure just returns only one value
? Basically, I pass two parameters to my stored procedure which inturn
returns a sequence number. Anyway, I have replaced this procedure by
a function, which is successfully compiled in the oracle database. Now
there is an error when I call this stored function in my application.
The stored procedure definition in my EOModeler is
procedure name : COPY_COURSE_FUNC
parameters
1. Name = copyCourseSeq
Direction = In
Value Class = NSNumber
External Type = NUMBER
column = 001
2. Name = user_Id
Direction = In
Value Class = NSString
External Type = Varchar2
column = 002
3. Name = returnValue
Direction = Out
Value Class = NSNumber
External Type = Number
column = 000
Now, how will I call the stored function "COPY_COURSE_FUNC" and how will
I fetch the return value.
This is the code that I used in WebObjects 4.5. I am trying to use the
same and obviously it results in some error.
EOModelGroup defaultGroup = EOModelGroup.defaultGroup();
//Get the default model name
NSArray anArray = defaultGroup.modelNames(); //Returns the
model names.
EOModel model =
defaultGroup.modelNamed((String)anArray.objectAtIndex(0));
//Set the adaptor channel
EODatabaseContext databaseContext =
EODatabaseContext.registeredDatabaseContextForModel(model, new
EOEditingContext());
EODatabaseChannel databaseChannel =
databaseContext.availableChannel();
EOAdaptorChannel adaptorChannel =
databaseChannel.adaptorChannel();
if (!adaptorChannel.isOpen()) {
adaptorChannel.openChannel();
}
EOAdaptorContext.setDebugEnabledDefault(true);
NSMutableDictionary parameters = new NSMutableDictionary();
//Parameter for the procedure
parameters.setObjectForKey(aCourse.course_seq(),
"copyCourseSeq");
parameters.setObjectForKey(this.session.loggedUser.user_Id(),
"user_Id");
EOStoredProcedure copyCourse =
defaultGroup.storedProcedureNamed("COPY_COURSE_FUNC"); //set the
stored procedure
adaptorChannel.executeStoredProcedure(copyCourse, parameters);
//execute the stored proecedure
parameters =
(NSMutableDictionary)adaptorChannel.returnValuesForLastStoredProcedureInvocation();
//Get the result
Thanks in advance for any kind of help.
Meena.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.