FOR-IN-EXECUTE, why fail?

From: mmarencibia(at)yahoo(dot)es (Marcos Medina)
To: "pgsql-general(at)postgresql(dot)org(dot)pgsql-novice(at)postgresql(dot)org(dot)pgsql-sql"(at)postgresql(dot)org
Subject: FOR-IN-EXECUTE, why fail?
Date: 2004-07-14 15:13:40
Message-ID: e0e689c2.0407140713.3e898cc8@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-sql

I wrote the following:
CREATE OR REPLACE FUNCTION escritorio.seq_valor_actual( text)
RETURNS integer AS '
DECLARE
secuencia ALIAS FOR $1;
valor_actual integer := 0;
v_query text;
actual integer;
BEGIN
RAISE NOTICE ''el parametro tiene el siguiente valor %'' ,secuencia;

v_query := ''SELECT last_value FROM '' || quote_ident(secuencia);
RAISE NOTICE ''la sentencia a ejecutar es %'' ,v_query;

FOR actual IN EXECUTE v_query LOOP
valor_actual := actual;
END LOOP;

RETURN valor_actual;

END;
'LANGUAGE 'plpgsql';

And i call:
select seq_valor_actual('s_id_reserva');

The s_id_reserva is a sequence. The error is the following:
WARNING: plpgsql: ERROR during compile of seq_valor_actual near line 12
ERROR: missing .. at end of SQL expression

I think the problem is in the FOR but i see correct all.

Can i help me?

Any idea?

Tahnks....

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert Treat 2004-07-14 19:17:30 determining supported timezones
Previous Message Tom Lane 2004-07-14 14:31:44 Re: Function and RowType

Browse pgsql-novice by date

  From Date Subject
Next Message Lynna Landstreet 2004-07-14 19:36:08 Re: Seaching with and without diacritical marks
Previous Message George Kola 2004-07-14 15:06:39 postgres array question

Browse pgsql-sql by date

  From Date Subject
Next Message Alexander M. Pravking 2004-07-14 18:51:07 Indexable (constant LIKE prefix_keyfield) ?
Previous Message Bruno Wolff III 2004-07-14 05:36:13 Re: schemas