| From: | "wilhelmtg(at)cantv(dot)net" <wilhelmtg(at)cantv(dot)net> |
|---|---|
| To: | pgsql-es-ayuda(at)postgresql(dot)org |
| Cc: | wilhelmtg(at)cantv(dot)net |
| Subject: | Totalizar tablas dinamicamente |
| Date: | 2006-11-16 23:57:34 |
| Message-ID: | 380-2200611416235734295@cantv.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-es-ayuda |
CREATE FUNCTION get_total_user2(varchar) RETURNS varchar AS'
DECLARE
table_name ALIAS FOR $1;
total integer;
BEGIN
SELECT count(*) INTO total FROM table_name WHERE status = 1;
RETURN total;
END;
'
LANGUAGE 'plpgsql' VOLATILE;
Buenas noches Srs.
Tengo un pequeño inconveniente con esta función
==========================================================
CREATE OR REPLACE FUNCTION get_total_user1("varchar") RETURNS int4 AS'
DECLARE
table_name ALIAS FOR $1;
total integer;
BEGIN
SELECT count(*) INTO total FROM table_name WHERE status = 1;
RETURN total;
END;
'
LANGUAGE 'plpgsql' VOLATILE;
==========================================================
Invocar la funcion
========================================
SELECT get_total_user1('nombre_tabla');
========================================
Esta funcion obtiene el número total de filas y me devuelve igualmente.
El nombre de la tabla debo pasar como parametro .
Si coloco el nombre de la tabla dentro de la sentencia SQL funciona
perfectamente, pero sucede lo contrario si el nombre de la tabla envio como
parametro.
Alguna sugerencia..
Gracias...
wilhelm
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hensa | 2006-11-17 02:09:17 | error al resguardar BD |
| Previous Message | jvital | 2006-11-16 23:51:20 | Orientacion sobre almacenar datos a una base de datos externa |