Hi guys,

i'm testing a v8.0beta4 in windows.

Welcome to psql 8.0.0beta4, the PostgreSQL interactive
terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

Warning: Console codepage (850) differs from windows
codepage (1252)
         8-bit characters will not work correctly. See
PostgreSQL
         documentation "Installation on Windows" for
details.

template1=# \c uescc
Ahora estß conectado a la base de datos "uescc".


***

This is a script i'm trying to run to replace an
existing function

**
-- begin script func.sql

BEGIN WORK;

DROP FUNCTION recaudaciones.rec_f_aperturarcaja(int2,
int2);

CREATE OR REPLACE FUNCTION
recaudaciones.rec_f_aperturarcaja(int2, int2)
  RETURNS void AS '
declare
        rs                      rec_t_actividadcaja%ROWTYPE;
        rs_ctran        rec_t_transaccion%ROWTYPE;
        rs_dtran        rec_t_detalletransaccion%ROWTYPE;
        rs_ttran        rec_m_tipotransaccion%ROWTYPE;
        valor_ef        DECIMAL(9,2);
        valor_ch        DECIMAL(9,2);
begin
        SELECT INTO rs * FROM rec_t_actividadcaja
         WHERE ent_codigo        = $1
           AND caj_codigo        = $2
           AND acj_fechaapertura = current_date;
        
        IF rs.ent_codigo IS NOT NULL THEN
                RETURN;
        END IF; 
        
        SELECT INTO rs * FROM rec_t_actividadcaja
         WHERE ent_codigo        = $1
           AND caj_codigo        = $2
        ORDER BY acj_fechaapertura DESC LIMIT 1;
        
        IF rs.ent_codigo IS NULL THEN
                valor_ef := 0;
                valor_ch := 0;
        ELSE
                valor_ef := rs.acj_valorefapertura;
                valor_ch := rs.acj_valorchapertura;
                
                FOR rs_ctran IN SELECT * FROM rec_t_transaccion
                                         WHERE ent_codigo              =
rs.ent_codigo
                                           AND caj_codigo              =
rs.caj_codigo
                                               AND DATE(tra_fechaingreso) >=
rs.acj_fechaapertura
                LOOP
                                        
                        SELECT INTO rs_ttran * FROM rec_m_tipotransaccion
                         WHERE ent_codigo = rs_ctran.ent_codigo
                           AND tra_codigo = rs_ctran.tra_codigo;

                        FOR rs_dtran IN SELECT * FROM
rec_t_detalletransaccion
                                                         WHERE ent_codigo = 
rs_ctran.ent_codigo
                                                           AND tra_anio   = 
rs_ctran.tra_anio
                                                           AND tra_codigo = 
rs_ctran.tra_codigo
                                                           AND tra_numero = 
rs_ctran.tra_numero
                                                           AND fpg_codigo IN (''EF'', 
''CH'')
                        LOOP
                                CASE rs_dtran.fpg_codigo
                                        WHEN ''EF'' THEN
                                                IF rs_ttran.tra_tipo = ''+'' THEN
                                                        valor_ef := valor_ef + 
rs_dtran.dtr_valor;
                                                ELSE
                                                        valor_ef := valor_ef - 
rs_dtran.dtr_valor;
                                                END IF;
                                        WHEN ''CH'' THEN
                                                IF rs_ttran.tra_tipo = ''+'' THEN
                                                        valor_ch := valor_ch + 
rs_dtran.dtr_valor;
                                                ELSE
                                                        valor_ch := valor_ch - 
rs_dtran.dtr_valor;
                                                END IF;
                                END;
                        END LOOP;
                END LOOP;
        END IF; 
        
        INSERT INTO rec_t_actividadcaja
        VALUES ($1, $2, current_date, current_time, valor_ef,
valor_ch);

        RETURN;

end; '
  LANGUAGE 'plpgsql' VOLATILE;
  
COMMIT WORK;

-- end script func.sql

*** 

These are the answers from psql

***

uescc=# \i c:/func.sql
BEGIN
DROP FUNCTION
psql:c:/func.sql:77: ERROR:  syntax error at or near
"ELSE" en el carßcter 1720
psql:c:/func.sql:77: LINE 53:       ELSE
psql:c:/func.sql:77:                ^
ROLLBACK
uescc=#


***

but in that line there is a valid IF .. THEN .. ELSE
block.


is it a bug? or i'm totally wrong?

regards, 
Jaime Casanova

_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to