RE: returning a single value from a database procedure in .NET (and byref)
- From: morgan brickley <morgan@xxxxxxxxxxxxx>
- Date: Fri, 22 Jul 2005 10:10:13 +0100
Dave - the solution you proposed does work indeed. Thanks ! Out of interest (and possible need down the line) - do I have the correct idea for passing by reference to .net ...
I make the procedure with an extra param 'out_userid;
create procedure usr_logon_ref (in_username varchar(45) not null not default , in_password varchar(45) not null not default , out_userid bigint not null not default)
I set this to be the correct value :
:out_userid = tempUID; end;
And I add an extra Output or InputOutput to the param list (first)
IngresCommand iCmd = new IngresCommand("usr_logon_ref", iConn);
iCmd.CommandType = CommandType.StoredProcedure;IngresParameter parm3 = new IngresParameter("out_userid", IngresType.BigInt);
cand then call using
iCmd.ExecuteNonQuery(); return (Int64)parm3.Value;
Should this work ? Do I need to use the escape sequence method again - why does the escape seq work and the 'direct; method not work -
I'm using version 3.
Dave - Thanks for all your help so far,
Cheers,
Morgan.
--- previous --- Make sure you are using release 3.0.2.105 or later. Bugs were fixed.
Use ExecuteNonQuery, not ExecuteScalar. The latter is used for result-sets that have one row and one column.
Try using the escape sequence form of calling the procedure and use parameter markers:
testCMD = new IngresCommand(
"{? = call usr_logon_rtn (?, ?)}",
conn);
testCMD.CommandType = CommandType.Text;<add parameters with ReturnValue parm first>
testCMD.ExecuteNonQuery();
Hope this helps, Dave .
- Prev by Date: INGRES SREPORT Problem
- Next by Date: RE: [Info-ingres] INGRES SREPORT Problem
- Previous by thread: INGRES SREPORT Problem
- Next by thread: RE: [Info-ingres] INGRES SREPORT Problem
- Index(es):