RE: Calling Ingres Database Procedures through .Net Data Provider



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.
.



Relevant Pages

  • RE: SQL stored procedure executing twice
    ... I wasn't aware that DLookupwould execute the "domain" more than once. ... caused the stored procedure to execute twice. ... Dim stDocName As String ... My pass-thru query properties ...
    (microsoft.public.access.modulesdaovba)
  • Re: Finally which ORM tool?
    ... of a query;), hence my question. ... IEnumerabledirectly but instead having an Execute method taking ... But it's not a problem with LINQ itself. ... Every Linq provider will implement ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: DeriveParameters and Jet OLEDB Provider
    ... retrieves provider-side parameter information for the stored procedure or ... parameterized query specified in the Command object. ... In Jet a 'saved' query is not a stored procedure. ... > method with this provider to populate a Paramters collection. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Weird SqlDataReader: Invalid attempt to read when no data is present.
    ... When I execute the stored ... I know my stored procedure is working ok. ... > the SQL Query analyser and got results. ... The data reader object's HasRows ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Finally which ORM tool?
    ... you manipulate the linq query IF you're ... implement IEnumerablebut had an Execute() method which gave ... Every Linq provider will implement ...
    (microsoft.public.dotnet.languages.csharp)