Problem with runstoredprocedure

I am trying to call a oracle procedure in matlab. The procedure is as follows:
PROCEDURE test(a number, b number, c OUT number) IS BEGIN c:=a+b; END;
I have made a oracle odbc driver using querybuilder function in matlab. then I have used the following commands to connect and run the procedure.
conn = database('connectionstring','dbusername','password');
database is connected and I am able to execute sql queries and fetch the data.
But when I am using the following command, >> results = runstoredprocedure(conn,'TEST',{'3','5'},'java.sql.Types.NUMERIC'); ??? Cell contents reference from a non-cell array object.
Error in ==> database.runstoredprocedure at 76 csmt.registerOutParameter(i,typeout{i});
Can anyone please let me know what is the mistake i am doing and What should i give for OUT parameter type here.
if i have a string in the place of NUMERIC as OUT parameter what is the OUT datatype to be given in the runstoredprocedure command???

1 Comment

Try {java.sql.Types.NUMERIC} instead of 'java.sql.Types.NUMERIC'

Sign in to comment.

Answers (1)

I have tried with Hello world example using oracle procedures.
Procedure:
PROCEDURE test(c OUT char,d OUT char,e OUT char) IS
BEGIN select 'Hello world' into c from dual; select 'Hey' into d from dual; select 'How r u??' into e from dual; END;
Using oracle odbc driver I have created a driver in matlab with querybuilder command. After that using the following code I am able to call oracle procedures.
s.DataReturnFormat = 'cellarray'; s.ErrorHandling = 'store'; s.NullNumberRead = 'NaN'; s.NullNumberWrite = 'NaN'; s.NullStringRead = 'null'; s.NullStringWrite = 'null'; s.JDBCDataSourceFile = ''; s.UseRegistryForSources = 'yes'; s.TempDirForRegistryOutput = 'C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp'; setdbprefs(s)
% Make connection to database. Note that the password has been omitted. % Using ODBC driver. conn = database('Hoststring','Database name','password');
x= runstoredprocedure(conn,'TEST',{},{java.sql.Types.CHAR,java.sql.Types.CHAR,java.sql.Types.CHAR});
here I am using 3 strings as output. For number use java.sql.Types.NUMERIC Output will be as follows: x =
[1x255 char]
[1x255 char]
[1x255 char]
>> x{1}
ans =
Hello world
>> x{2}
ans =
Hey
>> x{3}
ans =
How r u??
I think this will help many of them those who are trying to have connectivity between oracle and matlab. Luckly I am able to solve this. If there are any such successful trials please let me know ....

Asked:

on 25 Jun 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!