bueno eso es simple, lo que no logro hacer es los siguiente, crear un procedimiento almacenado en postgres es decir una funcion y que me retorne una lista completa y ello capturarlo en el visual net y mostrar en un datagrid, hasta ahora lo trabajo de la siguiente forma creo rudimentario pero me funciona bien si no necesito transaccion, pero tengo un gran problema, primero les muestro como trabajo
-- mi funcion en postgres
CREATE OR REPLACE FUNCTION "SGT".sgt_fn_getlist_cv_reciente_x_idvehiculo(idvehiculo integer)
RETURNS SETOF refcursor AS
$BODY$
DECLARE
ref1 refcursor;
BEGIN
OPEN ref1 FOR
select CV.* from "SGT"."SGT_tb_ConstTecVehiculo" CV,"SGT"."SGT_tb_VehiculoPropietario" VP
where CV."IdVehProp" = VP."IdVehProp" and
VP."IdVehiculo"=idvehiculo;
RETURN NEXT ref1;
RETURN;
END;
$BODY$
LANGUAGE plpgsql;
--forma de llamar a mi procedure
function getListaConstatacionVehicular(IdVehiculo) as datateble
return ADO_psg_Utilidad.getTable(Chr(34) & "SGT" & Chr(34) & ".sgt_fn_getlist_cv_reciente_x_idvehiculo", L)
end function
Public Shared Function getTable(ByVal storedProcedure As String, Optional ByVal parametro As List(Of Npgsql.NpgsqlParameter) = Nothing) As DataTable
Dim dt As New DataTable
Dim c As New Npgsql.NpgsqlCommand(storedProcedure, ADOFactory.getADOFactory.getCONEXION_BD)
Dim x As Npgsql.NpgsqlTransaction
c.CommandType = CommandType.StoredProcedure
x = ADOFactory.getADOFactory.getCONEXION_BD.BeginTransaction
If parametro Is Nothing Then
Else
For i As Integer = 0 To parametro.Count - 1
c.Parameters.Add(parametro.Item(i))
Next
End If
Dim dr As Npgsql.NpgsqlDataReader = Nothing
Try
dr = c.ExecuteReader
Catch ex As Exception
MsgBox(ex.Message)
End Try
dt.Load(dr)
dr.Close()
x.Commit()
Return dt
end function
Existe otra forma de llamar a una funcion hecha en postgres y que retorne el resultado de ejecutar una consulta sin usar transaccion como el caso anterior?, ya que con esto no puedo utilizar transaccion anida.. help meee mi correo
[email protected]