Greetings All,
I have been able to run the tutorial, and have been able to use
ibatis against my own application. However, I have not been able to
run a simple stored procedure.
Can someone please tell me what I am doing wrong.
Run against Firebirt 2.0 database Stored Procedure (no input
parameters - one output):
SQL> create or alter procedure gen_next_chld_id
CON> returns (childId integer)
CON> as
CON> begin childId = Gen_ID(child_sequence,27);
config file:
<procedure id="nextKid" parameterClass="pm1" >
gen_next_chld_id
</procedure>
</statements>
<parameterMaps>
<parameterMap id="pm1">
<parameter property="childId" direction="Output" />
</parameterMap>
</parameterMaps>
code to execute:
public int getNextKid()
{
Hashtable m = new Hashtable();
m.Add("chldId",0);
//int i = (int)Mapper().QueryForObject("nextKid",m);
Mapper().QueryForObject("nextKid",m);
int i = (int)m["childId"];
return i;
}
// code that calls getNext Kid()
Console.WriteLine("get ready for next Kid = ?");
i = 99;
i = Helpers.Child().getNextKid();
// i = Helpers.Child().selectNextKid(); //falure
Console.WriteLine("next Kid = "+ i.ToString());
Console.WriteLine("End of Test");
program output:
...
new childId = 138
get ready for next Kid = ?
As you can see, there is no error, but program execution stops - the
"next kid = " is never printed. "End of Test" is never printed.
So there are two errors: one, the stored procedure is not executed
and, two, the program stops abnormally but does not give an error.
Note - This code runs fine and produces the correct output:
S = "gen_next_chld_id";
FbCommand cmd = new FbCommand(S,c);
cmd.CommandText = S;
cmd.CommandType = CommandType.StoredProcedure;
FbParameter parm = new
FbParameter("@childId",FirebirdSql.Data.Firebird.FbDbType.Integer);
//MSSQL is picky
parm.Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.Add(parm);
cmd.ExecuteNonQuery();
int num = (int)parm.Value;
Console.WriteLine("new childId = " + num);
c.Close(); // now
One final twist, my provider for Ibatis.net is
<provider name="Odbc1.1" />. But, the above code with FbCommand is
using the Firebird .Net provider from firebird. I confess - I could
not get the "Firebird1.7" driver to work in ibatis. Other ibatis
commands like select and insert work fine with Odbc1.1.
I am confused - I have tried many variations of above - none have
worked. I searched the archives have found similar problems but no
solutions that have worked for me.
Thanks for any help. Dan Carlton