[Info-ingres] RE: returning a single value efficiently from a database procedure
- From: "Thole, David J" <David.Thole@xxxxxx>
- Date: Thu, 28 Jul 2005 11:38:23 -0400
Ingres r3 and the Ingres .NET Data Provider do support row-producing
database procedures. The row-producing db proc produces a result-set.
That result-set can be accessed by an IngresDataReader or by an
IngresDataAdapter to fill a DataSet. This is an example of an Ingres
row-producing db proc:
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
This is an example of accessing the result-set via an IngresDataReader:
Console.WriteLine("StoredProcedure RowProc");
cmd = new IngresCommand(
"rowproc", conn, txn);
cmd.CommandType = CommandType.StoredProcedure;
reader = cmd.ExecuteReader();
Console.WriteLine();
dt = reader.GetSchemaTable();
PrintDataTable(dt);
Console.Write("ColumnName='" + reader.GetName(0)
+ "'");
Console.WriteLine();
while (reader.Read())
{
Console.Write(reader.GetString(0) +
"\t");
}
Console.WriteLine();
reader.Close();
This is an example of accessing the result-set via an IngresDataAdapter
to fill a DataSet:
Console.WriteLine("StoredProcedure RowProc
Filled by DataAdapter");
cmd = new IngresCommand(
"rowproc", conn, txn);
cmd.CommandType = CommandType.StoredProcedure;
IngresDataAdapter adapter = new
IngresDataAdapter();
adapter.SelectCommand = cmd;
DataSet ds = new DataSet();
adapter.Fill(ds, "MyTables");
Console.WriteLine("------------------------");
Console.WriteLine("Results of adapter.Fill");
PrintDataSet(ds);
Console.WriteLine("------------------------");
Hope this helps,
Dave
.
- Prev by Date: Re: [Info-ingres] Friday is coming ...
- Next by Date: Re: returning a single value efficiently from a database procedure to .net in ingres (using IngresParameter.ReturnValue and ExecuteScalar)
- Previous by thread: TERM_INGRES for ssh client.
- Index(es):