porting vb6 code to pgplsql, referencing fields

Поиск
Список
Период
Сортировка
От josep porres
Тема porting vb6 code to pgplsql, referencing fields
Дата
Msg-id d2d532610803120414h1d04643at89ab41aa860c7303@mail.gmail.com
обсуждение исходный текст
Ответы Re: porting vb6 code to pgplsql, referencing fields  (Craig Ringer <craig@postnewspapers.com.au>)
Список 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




В списке pgsql-general по дате отправления:

Предыдущее
От: "josep porres"
Дата:
Сообщение: porting vb6 code to pgplsql, referencing fields
Следующее
От: David Wall
Дата:
Сообщение: Re: postgre vs MySQL