Mira las comillas no son comillas inclinadas y si quieres utilizar un select a 
la función lo tienes que hacer de esta forma: 

SELECT regexp_replace(v_template,'arial','DejaVu Sans') INTO v_local ; 

de lo contrario no utilices el SELECT y hazlo así: 

v_local := regexp_replace(v_template,'arial','DejaVu Sans'); 

Saludos y espero que te sirva. 



----- "Marcos Ortiz" <mlor...@uci.cu> escribió: 
> Saludos listeros. 
> Primeramente, el ambiente de trabajo: 
> ------------------------------------ 
> S.O: Ubuntu 10.10 64 bits 
> Version de PostgreSQL: 
> 
> version 
> -----------------------------------------------------------------------------------------------------------------
>  
> PostgreSQL 9.0.1 on x86_64-unknown-linux-gnu, compiled by GCC gcc 
> (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5, 64-bit 
> (1 row) 
> 
> ------------------------------------ 
> 
> Necesito realizar una función que me permita reemplazar un texto en un 
> determinado campo text, pero me está dando un error. 
> 
> ----------- 
> ERROR: syntax error at or near "SELECT" 
> LINE 20: v_local := SELECT regexp_replace(v_template,`arial`,`De... 
> 
> ----------- 
> 
> La función que estoy haciendo es la siguiente: 
> 
> CREATE OR REPLACE FUNCTION modificar_letra_tbreport() RETURNS VOID AS 
> $$ 
> DECLARE 
> -- Declaracion de las variables a usar 
> v_row record; 
> v_template text; 
> v_xmlreport text; 
> v_local text; 
> v_local2 text; 
> BEGIN 
> SET search_path = 'mod_recuperaciones'; 
> -- Obtencion de todos los id de los reportes 
> 
> FOR v_row IN SELECT * FROM tbreport 
> LOOP 
> -- Obtencion de las variables a modificar 
> v_template := v_row.template; 
> v_xmlreport := v_row.xmlreport; 
> -- Reemplazo de arial por DejaVu Sans 
> v_local := SELECT regexp_replace(v_template,`arial`,`DejaVu Sans`); 
> v_local2 := SELECT regexp_replace(v_xmlreport,`arial`,`DejaVu 
> Sans`); 
> -- Actualizacion de las filas 
> UPDATE tbreport 
> SET template = v_local, 
> xmlreport = v_local2 
> WHERE idreport = v_row.idreport; 
> END LOOP; 
> END 
> $$ 
> lANGUAGE plpgsql; 
> 
> La tabla sobre la cual quiero aplicar la modificacion tiene el siguiente 
> formato: 
> 
> ------------------------ 
> Table "mod_recuperaciones.tbreport" 
> Column | Type | 
> Modifiers 
> ----------------+-----------------------------+----------------------------------------------------
>  
> idreport | integer | not null default 
> nextval('tbreport_seq'::regclass) 
> template | text | not null 
> modifiable | boolean | not null 
> query | text | not null 
> excecutiontime | timestamp without time zone | 
> parentid | integer | not null 
> xmlreport | text | not null 
> title | character varying(250) | not null 
> image | bytea | 
> created_on | timestamp without time zone | not null 
> updated_on | timestamp without time zone | not null 
> modifiedbyid | integer | not null 
> createbyid | integer | not null 
> Indexes: 
> "pk_tbreport" PRIMARY KEY, btree (idreport) 
> "title" UNIQUE, btree (title) 
> Foreign-key constraints: 
> "tbreporttbreport" FOREIGN KEY (parentid) REFERENCES 
> tbreport(idreport) ON UPDATE CASCADE ON DELETE CASCADE 
> "tbreporttbus6" FOREIGN KEY (createbyid) REFERENCES tbuser(iduser) 
> ON UPDATE CASCADE ON DELETE CASCADE 
> "tbreporttbuser" FOREIGN KEY (modifiedbyid) REFERENCES 
> tbuser(iduser) ON UPDATE CASCADE ON DELETE CASCADE 
> Referenced by: 
> TABLE "tbreportmodel" CONSTRAINT "reportmodel" FOREIGN KEY 
> (idreport) REFERENCES tbreport(idreport) ON DELETE CASCADE 
> TABLE "tbcategoryreport" CONSTRAINT "tbcategoryreporttbreport" 
> FOREIGN KEY (idreport) REFERENCES tbreport(idreport) ON UPDATE CASCADE 
> ON DELETE CASCADE 
> 
> ------------------------------------------------------------------- 
> El campo template tiene en su interior la definicion del formato de un 
> reporte determinado: color, tipo de letra, familia de la letra, etc. 
> 
> Y el campo xmlreport, tiene lo mismo en un formato de xml. 
> 
> Lo que pretendo hacer es modificar donde quiera que aparezca 'arial', 
> poner 'DejaVu Sans', pero me da el error comentado arriba. 
> 
> Cualquier sugerencia es bienvenida 
> 
> -- 
> Marcos Luís Ortíz Valmaseda 
> 
> Centro de Tecnologías de Gestión de Datos (DATEC) 
> 
> 
> - 
> Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda@postgresql.org) 
> Para cambiar tu suscripci�n: 
> http://www.postgresql.org/mailpref/pgsql-es-ayuda 
>

Responder a