Hi everyone,
I'm trying to port some vb6 code to pgplsql (PostgreSQL 8.3 winxp)
that code is
Const f2_MAX_TRAMS = 5
Dim f2_rTarifaA as new ADODB.Recordset
Dim Mpa(f2_MAX_TRAMS) As Double ' preu aigua
Dim Ma(f2_MAX_TRAMS) As Long ' m3 aigua tarifa
Dim i As Integer, j As Integer ' indexs matrius
...
( open connection, open recordset, etc )
...
-- fill array with field values of M3TRAM1, ..., M3TRAM5
-- PREU1, ..., PREU5
for i = 1 to f2_MAX_TRAMS
Ma(i) = f2_rTarifaA.Fields("M3TRAM" + CStr(i)).Value
Mpa(i) = f2_rTarifaA.Fields("PREU" + CStr(i)).Value
next
in pgplsql, more or less
DECLARE
c_tarifa_c CURSOR (dfac DATE, key INTEGER) IS SELECT * FROM F2_TARIFA_C WHERE TIPUS = key AND dfac BETWEEN DINICI AND DFINAL;
f2_MAX_TRAMS CONSTANT INTEGER := 5;
Ma INTEGER[5];
Mpa NUMERIC(10,2)[5];
row_tfa f2_tarifa_a%rowtype;
BEGIN
OPEN c_tarifa_a (datafac, f2_Mtar);
FETCH c_tarifa_a INTO row_tfa;
CLOSE c_tarifa_a;
For i IN 1..f2_MAX_TRAMS LOOP
Ma[i] := row_tfa. ????? -- "M3TRAM" + CStr(i)).Value
Mpa[i] := row_tfa. ????? -- "PREU" + CStr(i)).Value
END LOOP;
END
I would like to know some tips about:
How can I declare arrays especifying the size with a constant,
but the most important is how can I reference the fields inside de loop
Thanks in advance
Josep
I'm trying to port some vb6 code to pgplsql (PostgreSQL 8.3 winxp)
that code is
Const f2_MAX_TRAMS = 5
Dim f2_rTarifaA as new ADODB.Recordset
Dim Mpa(f2_MAX_TRAMS) As Double ' preu aigua
Dim Ma(f2_MAX_TRAMS) As Long ' m3 aigua tarifa
Dim i As Integer, j As Integer ' indexs matrius
...
( open connection, open recordset, etc )
...
-- fill array with field values of M3TRAM1, ..., M3TRAM5
-- PREU1, ..., PREU5
for i = 1 to f2_MAX_TRAMS
Ma(i) = f2_rTarifaA.Fields("M3TRAM" + CStr(i)).Value
Mpa(i) = f2_rTarifaA.Fields("PREU" + CStr(i)).Value
next
in pgplsql, more or less
DECLARE
c_tarifa_c CURSOR (dfac DATE, key INTEGER) IS SELECT * FROM F2_TARIFA_C WHERE TIPUS = key AND dfac BETWEEN DINICI AND DFINAL;
f2_MAX_TRAMS CONSTANT INTEGER := 5;
Ma INTEGER[5];
Mpa NUMERIC(10,2)[5];
row_tfa f2_tarifa_a%rowtype;
BEGIN
OPEN c_tarifa_a (datafac, f2_Mtar);
FETCH c_tarifa_a INTO row_tfa;
CLOSE c_tarifa_a;
For i IN 1..f2_MAX_TRAMS LOOP
Ma[i] := row_tfa. ????? -- "M3TRAM" + CStr(i)).Value
Mpa[i] := row_tfa. ????? -- "PREU" + CStr(i)).Value
END LOOP;
END
I would like to know some tips about:
How can I declare arrays especifying the size with a constant,
but the most important is how can I reference the fields inside de loop
Thanks in advance
Josep