Using oracle functions
Using oracle functions
I'm trying to understand how a simple oracle function (returning a string) can be used with the entity framework 4. I'm using the devart entity developer to create my edmx.
I'm only able to get this working when adding an output parameter in the entity method and setting the value by using the command text (ie: begin :result := mySchema.testfunction(); end;)
and then calling the function in visual studio with the output parameter:
ObjectParameter param = new ObjectParameter("result", "");
myObjectcontext.ExecuteFunction("Testfunction", param);
MessageBox.Show(param.Value.ToString());
But this seems to be a bit stupid, I would like to use the function like this:
ObjectResult result = myObjectcontext.ExecuteFunction("Testfunction");
My question is how to setup the entitymethod for this to work, I've set the return type to string and mapped to the oracle function but this results in a "PLS-00306: wrong number or types of arguments in call to 'TESTFUNCTION" error message.
Can anyone help or is there some documentation on the subject?
Many thanks
I'm only able to get this working when adding an output parameter in the entity method and setting the value by using the command text (ie: begin :result := mySchema.testfunction(); end;)
and then calling the function in visual studio with the output parameter:
ObjectParameter param = new ObjectParameter("result", "");
myObjectcontext.ExecuteFunction("Testfunction", param);
MessageBox.Show(param.Value.ToString());
But this seems to be a bit stupid, I would like to use the function like this:
ObjectResult result = myObjectcontext.ExecuteFunction("Testfunction");
My question is how to setup the entitymethod for this to work, I've set the return type to string and mapped to the oracle function but this results in a "PLS-00306: wrong number or types of arguments in call to 'TESTFUNCTION" error message.
Can anyone help or is there some documentation on the subject?
Many thanks
Please perform the following steps:
1. Drag the Testfunction function on the designer surface.
2. Go to the Moder Explorer->Model.Store. Edit the properties of this function: set Concealed to true.
3. Drag the function from the Model.Store to the designer surface.
4. Change the Return Type of the generated method (Model Explorer->Methods->Testfunction->Properties) to String.
1. Drag the Testfunction function on the designer surface.
2. Go to the Moder Explorer->Model.Store. Edit the properties of this function: set Concealed to true.
3. Drag the function from the Model.Store to the designer surface.
4. Change the Return Type of the generated method (Model Explorer->Methods->Testfunction->Properties) to String.
Thank you for you reply, I’ve amended the properties like you explained. When I try to execute the code I get an error: EntityCommandExecutionException: The data reader returned by the store data provider does not have enough columns for the query requested.
I’m calling the function using:
ObjectResult result = EFContext.ExecuteFunction("Testfunction");
It seems like the result of the database function is not passed to the result of the generated method.
I’m calling the function using:
ObjectResult result = EFContext.ExecuteFunction("Testfunction");
It seems like the result of the database function is not passed to the result of the generated method.
Call the function like in the following snippet:
Code: Select all
string s = myObjectcontext.Testfunction();
Take a look at the POCO template discussion.
It contains links to some corrections associated with the Stored Procedures.
It contains links to some corrections associated with the Stored Procedures.
My function is only returning a single string:
CREATE OR REPLACE FUNCTION JIT.testfunction
RETURN VARCHAR2
IS
BEGIN
RETURN 'Test function = OK!!';
END;
/
How can I 'tell' the entity developer that it is returning a single string?
These are my settings:
Aggregate False
Built In False
Command Test
Composable False
Concealed Function True
Name TESTFUNCTION
Niladic False
Parameter Type Semantics AllowImplicitConversion
Result Set Parameter Name
Return Type VARCHAR2
Schema JIT
Store Procedure Name
CREATE OR REPLACE FUNCTION JIT.testfunction
RETURN VARCHAR2
IS
BEGIN
RETURN 'Test function = OK!!';
END;
/
How can I 'tell' the entity developer that it is returning a single string?
These are my settings:
Aggregate False
Built In False
Command Test
Composable False
Concealed Function True
Name TESTFUNCTION
Niladic False
Parameter Type Semantics AllowImplicitConversion
Result Set Parameter Name
Return Type VARCHAR2
Schema JIT
Store Procedure Name