odbc + refcursor + vb6
am 05.05.2009 00:23:07 von jayalaThis is a multi-part message in MIME format.
------=_NextPart_000_00BD_01C9CCDC.FD8E90A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi everybody, i have migrated one vb6 app from mssql2000 to postgresql =
8.3, my database have a lot of stored functions.. i use refcursor type =
to return data from it. when i use the oledb driver it's ok.. well with =
few records ok.. but with thousands its very slow.. so i try the odbc =
driver.. and it works fine, but, not recognize my refcursor type only =
record type. With refcursor type I only receive the name of my =
refcursor. what is the solution to fetch the records in my refcursor.
I use tha next vb6 code for example
=20
Conn.BeginTrans
Cmd.ActiveConnection =3D Conn
Cmd.CommandText =3D "select=20
kardexf('017033','01/04/2009','30/04/2009','data');FETCH ALL IN data;"
Set Rst =3D Cmd.Execute
Do Until Rst.EOF
Me.List1.AddItem Rst.Fields(0) 'Rst!Movimiento
Rst.MoveNext
Loop
Rst.Close
Conn.CommitTrans
CREATE OR REPLACE FUNCTION "public"."dvalss_kardexf" (vcodalm char, =
vcodprod char, vfechaini timestamp, vfechafin timestamp, out data =
"pg_catalog"."refcursor") RETURNS "pg_catalog"."refcursor" AS
$body$
DECLARE
--data refcursor;
BEGIN
OPEN data FOR=20
SELECT * FROM cromoadmin.CentroCto CC RIGHT JOIN
(cromoadmin.DetValesAlm Det INNER JOIN cromoadmin.Vales Cab =
ON=20
DEt.Sucr_codigo =3D cab.Sucr_codigo and=20
Det.VALE_NumVale =3D Cab.VALE_NumVale AND =20
Det.ALMA_Codigo =3D Cab.ALMA_Codigo AND=20
Det.TIPO_TabVale =3D Cab.TIPO_TabVale AND =20
Det.TIPO_CodVale =3D Cab.TIPO_CodVale)
ON CC.Cent_cod=3DCab.CENT_Cod =20
INNER JOIN cromoadmin.Catalogos ON=20
Det.SUCR_Codigo =3D Catalogos.SUCR_Codigo AND
Det.PROD_CodProd =3D Catalogos.PROD_CodProd AND=20
Det.ALMA_Codigo =3D Catalogos.ALMA_Codigo INNER JOIN =
cromoadmin.Tipos Tip ON=20
CAb.TIPO_TabVale =3D Tip.TIPO_CodTabla AND=20
Cab.TIPO_CodVale =3D Tip.TIPO_CodTipo =20
LEFT OUTER JOIN cromoadmin.CtaCtePRov CCP on ccp.ccpr_nroTran =
=3D det.ccpr_nroTran and=20
ccp.SUCR_Codigo =3D det.SUCR_Codigo
WHERE Det.ALMA_Codigo =3D vCodAlm And
Det.PROD_CodProd =3D vCodProd And
Cab.VALE_FecEmi BetWeen vFechaIni AND vFechaFin And
Cab.VALE_Estado <>'X' ORDER BY Cab.VALE_FecEmi, =
Cab.VALE_Efecto, Cab.TIPO_CodVale Desc;
RETURN;
END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;
Thanks a lot.
---
Jose J. Ayala Pineda (a.k.a. 1nk@H@ck)
MSN Messenger: jjap@hotmail.com
URL/Blog: http://inkahack.blogspot.com
"Si t=FA tienes una manzana y yo tengo una manzana y las intercambiamos, =
entonces ambos a=FAn tendremos una manzana. Pero si t=FA tienes una idea =
y yo tengo una idea y las intercambiamos, entonces ambos tendremos dos =
ideas".
George Bernard Shaw
------=_NextPart_000_00BD_01C9CCDC.FD8E90A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
charset=3Diso-8859-1">
app from=20
mssql2000 to postgresql 8.3, my database have a lot of stored =
functions.. i use=20
refcursor type to return data from it. when i use the oledb driver it's =
ok..=20
well with few records ok.. but with thousands its very slow.. so i try =
the odbc=20
driver.. and it works fine, but, not recognize my refcursor type only =
record=20
type. With refcursor type I only receive the name of my refcursor. what =
is the=20
solution to fetch the records in my refcursor.
example
Conn.BeginTrans
Cmd.ActiveConnect=
ion =
Conn
Cmd.CommandText =3D "select=20
kardexf('017033','01/04/2009','30/04/2009','data');FETCH ALL IN=20
data;"
Set Rst =3D Cmd.Execute
Do Until =
Rst.EOF
=20
Me.List1.AddItem Rst.Fields(0)=20
'Rst!Movimiento
Rst.MoveNext
Loop
Rst.Close
> Conn.Comm face=3DArial size=3D2> size=3D3>itTrans
"public"."dvalss_kardexf" (vcodalm char, vcodprod char, vfechaini =
timestamp,=20
vfechafin timestamp, out data "pg_catalog"."refcursor") RETURNS=20
"pg_catalog"."refcursor" AS
$body$
DECLARE
--data=20
refcursor;
BEGIN
OPEN data FOR
=
SELECT * FROM cromoadmin.CentroCto CC RIGHT=20
JOIN
=
(cromoadmin.DetValesAlm=20
Det INNER JOIN cromoadmin.Vales Cab ON=20
=20
DEt.Sucr_codigo =3D cab.Sucr_codigo and=20
=20
Det.VALE_NumVale =3D Cab.VALE_NumVale AND =20
=20
Det.ALMA_Codigo =3D Cab.ALMA_Codigo AND=20
=20
Det.TIPO_TabVale =3D Cab.TIPO_TabVale=20
AND =20
=20
Det.TIPO_CodVale =
Cab.TIPO_CodVale)
&nbs=
p; =20
ON CC.Cent_cod=3DCab.CENT_Cod =20
INNER =20
JOIN cromoadmin.Catalogos ON=20
=20
Det.SUCR_Codigo =3D Catalogos.SUCR_Codigo =20
AND
=
=20
Det.PROD_CodProd =3D Catalogos.PROD_CodProd AND=20
&nb=
sp; =20
Det.ALMA_Codigo =3D Catalogos.ALMA_Codigo INNER JOIN=20
cromoadmin.Tipos Tip ON=20
&nb=
sp; =20
CAb.TIPO_TabVale =3D Tip.TIPO_CodTabla AND=20
&nb=
sp; =20
Cab.TIPO_CodVale =3D Tip.TIPO_CodTipo =20
LEFT OUTER JOIN=20
cromoadmin.CtaCtePRov CCP on ccp.ccpr_nroTran =3D det.ccpr_nroTran and=20
&nb=
sp; =20
ccp.SUCR_Codigo =3D =
det.SUCR_Codigo
=20
WHERE Det.ALMA_Codigo =3D vCodAlm=20
And
Det.PROD_CodProd =
=
vCodProd And
=
Cab.VALE_FecEmi=20
BetWeen vFechaIni AND vFechaFin=20
And
Cab.VALE_Estado=20
<>'X' ORDER BY Cab.VALE_FecEmi, Cab.VALE_Efecto, =
Cab.TIPO_CodVale=20
Desc;
RETURN;
END;
$body$
LANGUAGE=20
'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY =
INVOKER
COST=20
100;
Thanks a =
lot.
Jose J. Ayala Pineda (a.k.a. href=3D"mailto:1nk@H@ck">1nk@H@ck)
MSN Messenger: href=3D"mailto:jjap@hotmail.com">jjap@hotmail.com
URL/Blog: href=3D"http://inkahack.blogspot.com">http://inkahack.blogsp ot.com
>"Si tĂș
tienes una manzana y yo tengo una manzana y las intercambiamos, entonces =
ambos=20
a=FAn tendremos una manzana. Pero si t=FA tienes una idea y yo tengo una =
idea y las=20
intercambiamos, entonces ambos tendremos dos ideas".
George Bernard=20
Shaw
------=_NextPart_000_00BD_01C9CCDC.FD8E90A0--