porting vb6 code to pgplsql, referencing fields

From: "josep porres" <jmporres(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: porting vb6 code to pgplsql, referencing fields
Date: 2008-03-12 11:30:30
Message-ID: d2d532610803120430u3e8b2405i4c373cf06ab5379b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2008-03-12 11:48:22 Re: FROM + JOIN when more than one table in FROM
Previous Message josep porres 2008-03-12 11:28:12 porting vb6 code to pgplsql, referencing fields