RE: Calling Ingres Database Procedures through .Net Data Provider
- From: morgan brickley <morgan@xxxxxxxxxxxxx>
- Date: Fri, 15 Jul 2005 13:27:51 +0100
Thole, David J wrote:
Ingres r3 supports row-producing procedures. The Ingres .NET Data Provider reads the result set produced by that procedure just as any result set produced by a query.
If the procedure is something like this:
drop procedure rowproc \p\g
create procedure rowproc
result row(char(32)) as
declare tabname char(32);
begin
for select table_name into :tabname from iitables
do
return row(:tabname);
endfor;
end;
\p\g
The .NET application would execute the procedure and read the result set like this:
IDataReader reader = null;
cmd = new IngresCommand(
"rowproc", conn, txn); //"{ call rowproc}", conn, txn);
cmd.CommandType = CommandType.StoredProcedure;
reader = cmd.ExecuteReader();
Console.Write("ColumnName='" + reader.GetName(0) + "'");
Console.WriteLine();
while (reader.Read())
{
Console.Write(reader.GetString(0) + "\t");
}
Console.WriteLine();
reader.Close();
Hope this helps,
Dave
That's almost what I'm looking for too. I need to return data from a stored procedure in a way that it is accepted with open arms into a DataSet.
I'm also wondering which method is better practice when calling a stored procedure - specifying the parameters using the provided classes lie this :
IngresCommand iCmd = new IngresCommand("usr_add", iConn);
iCmd.CommandType = CommandType.StoredProcedure;IngresParameter parm1 = new IngresParameter("in_username",IngresType.NVarChar,45);
IngresParameter parm2 = new IngresParameter("in_password",IngresType.NVarChar,45);
parm1.Value = usrName;
parm2.Value = pwd; parm1.Direction = ParameterDirection.Input;
parm2.Direction = ParameterDirection.Input; iCmd.Parameters.Add(parm1);
iCmd.Parameters.Add(parm2); try
{
int numRows = iCmd.ExecuteNonQuery();
return true;
}or just embedding the parameters in the command string itself :
string iCmdText = @"execute procedure usr_delete (in_username='" + usrName + @"', in_password='" + pwd @"')";
IngresCommand iCmd = new IngresCommand(iCmdText, iConn);
where usrName and pwd are strings...
Morgan. .
- Prev by Date: jdbc-query tracing/logging
- Next by Date: Re: [Info-ingres] jdbc-query tracing/logging
- Previous by thread: jdbc-query tracing/logging
- Next by thread: [Info-ingres] Obtaining SQL statement that was just perfor med
- Index(es):
Relevant Pages
|