Re: [Pgsql-ayuda] Cual es el error

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Edwin Quijada <listas_quijada(at)hotmail(dot)com>
Cc: pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx
Subject: Re: [Pgsql-ayuda] Cual es el error
Date: 2003-09-03 02:59:08
Message-ID: 20030903025908.GC25833@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

On Tue, Sep 02, 2003 at 10:57:28PM +0000, Edwin Quijada wrote:

> No le gusto tampoco!! Tiro la toalla!!! :(

Ok, esto funciona:

alvherre=> CREATE OR REPLACE FUNCTION cortar_char(name, name, varchar) RETURNS int4 AS '
DECLARE
tabla ALIAS FOR $1;
campo ALIAS FOR $2;
dato ALIAS FOR $3;
len int;
reg record;
BEGIN
select into reg b.atttypmod - 4 as lon
from pg_class a, pg_attribute b, pg_type c
where a.relname = tabla
and b.attrelid = a.relfilenode
and b.attname = campo
and b.attnum >0
and b.atttypid = c.oid;
len:=reg.lon;
return len;
END;'
LANGUAGE 'plpgsql';
CREATE

alvherre=> create table foo (uno varchar(20));
CREATE

alvherre=> select cortar_char('foo'::name, 'uno'::name, 'uno dos tres cuatro cinco seis siete'::varchar);
cortar_char
-------------
20
(1 registro)

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"A wizard is never late, Frodo Baggins, nor is he early.
He arrives precisely when he means to." (Gandalf, en LoTR FoTR)

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Edwin Quijada 2003-09-03 04:42:23 [Pgsql-ayuda] Longitud de campos string
Previous Message Alvaro Herrera 2003-09-03 02:47:27 Re: [Pgsql-ayuda] Error LOG