pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: mmarencibia@yahoo.es
To: " <pgsql-general@postgresql.org.pgsql-novice>
Subject: FOR-IN-EXECUTE, why fail?
Date: 14 Jul 2004 08:13:40 -0700
Message-ID: <e0e689c2.0407140713.3e898cc8@posting.google.com> (raw)

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....



view thread (3+ messages)  latest in thread

Message-ID: <e0e689c2.0407140713.3e898cc8@posting.google.com>
Permalink:  ../e0e689c2.0407140713.3e898cc8@posting.google.com/
Also on:    postgresql.org/message-id/e0e689c2.0407140713.3e898cc8@posting.google.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mmarencibia@yahoo.es, pgsql-general@postgresql.org.pgsql-novice
  Subject: Re: FOR-IN-EXECUTE, why fail?
  In-Reply-To: <e0e689c2.0407140713.3e898cc8@posting.google.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox