Re: insert into plpython

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: fernando villarroel <bbddlinux(at)yahoo(dot)es>
Cc: Oswaldo Hernández <listas(at)soft-com(dot)es>, pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: insert into plpython
Date: 2006-03-23 19:51:05
Message-ID: 20060323195105.GC7859@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

fernando villarroel escribió:
> Hola si probe entrecomillar, pero se cae
>
> create or replace function ingreso(varchar) returns
> text as '
> query="insert into cliente (nombre) values ('%s')"
> % (args[0])
> plpy.execute(query)
> return query
> ' LANGUAGE 'plpythonu';
>
> sigven=# \i FunIngreso.sql
> psql:FunIngreso.sql:5: ERROR: syntax error en o cerca
> de "%" at character 111

No has escapado las comillas. Prueba asi:

create or replace function ingreso(varchar) returns
text as $$
query="insert into cliente (nombre) values ('%s')" % (args[0])
plpy.execute(query)
return query
$$ LANGUAGE 'plpythonu';

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Luis Rodrigo Gallardo Cruz 2006-03-23 19:59:04 Atrapar el error de un cast.
Previous Message Julio Rivero 2006-03-23 19:43:17 Re: Access97 a Postgresql